发布时间:2019-09-14 09:26:43编辑:auto阅读(3022)
首页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集合操作
51102
50494
41105
37957
32423
29324
28197
23038
23006
21329
1360°
2055°
1713°
1645°
1934°
1717°
2391°
4029°
3919°
2799°