发布时间:2019-09-14 09:26:43编辑:auto阅读(3392)
首页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集合操作
53073
39990
34372
30123
25018
24824
23199
16666
14834
14332
655°
616°
674°
692°
741°
868°
834°
854°
951°
874°