发布时间:2019-09-14 09:26:43编辑:auto阅读(3053)
首页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集合操作
51322
50775
41369
38175
32660
29548
28391
23267
23236
21560
1637°
2371°
1975°
1916°
2245°
1951°
2646°
4435°
4273°
3044°