import pymysql
db = pymysql.connect(
host="localhost",
user="root",
password="123456789",
db="world"
)
cursor = db.cursor()
sql = '''CREATE TABLE zhangsan (
sno CHAR(10) PRIMARY KEY,
sname VARCHAR(20),
phone CHAR(11),
quarters VARCHAR(10)
);'''
cursor.execute(sql)
cursor.execute("show tables;")
print(cursor.fetchone())
print(cursor.fetchone())
data = cursor.fetchall()
for i in data:
print(i)
cursor.execute("INSERT INTO zhangsan VALUES ('230303050', 'zhangsan', '18888888888', '1A414');");
db.commit()
db.close()
© 版权声明
THE END
暂无评论内容