python mysql desc
时间:2021-07-01 10:21:17
帮助过:3人阅读
!/usr/bin/python
import MySQLdb
try:
conn=MySQLdb.connect(host=
‘localhost‘,user=
‘root‘,passwd=
‘yourpasswd‘,db=
‘yourdb‘)
cur=
conn.cursor()
cur.execute(‘desc bus_gps‘)
rows=
cur.fetchall()
desc =
cur.description
name_type_dict=
{}
for row
in rows:
name_type_dict[str(row[0])]=row[1
]
print row[0],row[1
]
cur.close()
conn.close()
print name_type_dict
except MySQLdb.Error,e:
print ‘Mysql Error %d: %s‘ % (e.args[0],e.args[1])
python mysql desc
标签: