标签:connect comm form mit tab password auto pymysql column
import pymysql
conn = pymysql.connect(host="127.0.0.1",user="root",password="123456",db="study",autocommit=True)
cur = conn.cursor()
sql = "select COLUMN_NAME from information_schema.COLUMNS where table_name = 'userinfo'"
cur.execute(sql)
for field in cur.fetchall():
print(field[0])
cur.close()
conn.close()
import pymysql
conn = pymysql.connect(host="127.0.0.1",user="root",password="123456",db="study",autocommit=True)
cur = conn.cursor()
sql = "select * from userinfo"
result = cur.execute(sql)
desc = cur.description
for field in desc:
print(field[0])
cur.close()
conn.close()
标签:connect comm form mit tab password auto pymysql column
原文地址:https://www.cnblogs.com/jruing/p/12458117.html