使用 MySQLdb 模块连接 MySQL
| 
 1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
 | 
# coding=utf-8 #引入mysql python客户端模块import MySQLdbimport sys#进行数据库连接conn= MySQLdb.connect(host="localhost", user="root", passwd="123456", db="pythontab", charset="utf8")cursor= conn.cursor()#执行sqlcursor.execute("select * from test")#列出数据records= cursor.fetchall()for rowin records:    for rin row:        print r | 
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
    











暂无评论内容