#!/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连接SQL Server 数据库几个关键点
- python获取00~23格式,小时数补全00
- Python中的os.environ()
- python 出现socket.gaierror: [Errno 11004] getaddrinfo failed错误
- mysql:Job for mysqld.service failed because the control process exited with error
- 解决MySQL服务无法启动,重置root用户密码
- Python OpenCV TypeError: Layout of the output array img is incompatible with cv
- python练手经典100例-非常适合Python菜鸟练手的趣味题(内附学习教程分享)
- 用Python修复百年老照片,那些高颜值的父母!
- 在windows下通过sqlyog连接ubantu下docker中的mysql5.5服务