发布时间:2019-09-14 09:26:43编辑:auto阅读(2799)
首页Python学习应用文章阅读 字体:小 中 大
日期:2014-06-26 17:43:12浏览:15次评论:0条作者:ylxhzjw评论
#!/usr/bin/env python #coding=utf-8 import MySQLdb #建立和数据库系统的连接 conn = MySQLdb.connect(host='localhost', user='root',passwd='test') #选择数据库 conn.select_db('python'); cursor.execute('set profiling = 1') #获取操作游标 cursor = conn.cursor() a=cursor.execute("""select * from test """) print a print cursor.fetchall() try: cursor.execute('SELECT * FROM aaa where name = %s',[admin]) except Exception: cursor.execute('show profiles') for row in cursor: print(row) cursor.execute('set profiling = 0') conn.close()
文章来源:
http://blog.zhanjingwen.cn/python-%e8%be%93%e5%87%basql%e8%af%ad%e5%8f%a5/
下一篇:需要读的几本专业书
上一篇: cocos2dx[3.2](3) ——大
下一篇: Python中的SET集合操作
48728
47766
38539
35734
30170
26912
25940
20783
20551
18939
328°
405°
440°
461°
446°
435°
489°
559°
674°
690°