25.04.2025

База данных реквизиты

https://82.146.35.88:1501/vhyqSfRzzO6eAely/phpmyadmin/index.php?route=/&route=%2

Логин: school
Пароль: Q1w2e3r4

host: 82.146.35.88
База данных: school
import pymysql

connection = pymysql.connect(host='82.146.35.88',
                             user='school',
                             password='Q1w2e3r4',
                             db='school',
                             charset='cp1251',
                             cursorclass=pymysql.cursors.DictCursor)

def cret():
    cursor = connection.cursor()
    cursor.execute("CREATE TABLE IF NOT EXISTS table2 (id int NOT NULL AUTO_INCREMENT, name text, phone text, description text, PRIMARY KEY (id));")
    connection.commit()
    cursor.close()
    connection.close()

def ins():
    cursor = connection.cursor()
    cursor.execute("insert into table2 (name, phone, description) VALUES (1,2,3)")
    connection.commit()
    cursor.close()
    connection.close()

def sel():
    cursor = connection.cursor()
    cursor.execute("SELECT * FROM table2")
    result = cursor.fetchall()  # в виде строки
    cursor.close()
    connection.close()
    for i in result:
        print(i)

# cret()
# ins()
sel()

Добавить комментарий