码迷,mamicode.com
首页 > 数据库 > 详细

python中mysql使用

时间:2015-05-12 20:58:45      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

MySQLdb使用程序

#!/bin/env python
import MySQLdb 

conn = MySQLdb.connect(host = "", user="", passwd="", port=8307, db="")
cursor = conn.cursor()

try:
    cursor.execute(sql)
    data = cursor.fetchall()
    conn.commit()
except MySQLdb.Error, e:
    print e

cursor.close()

for row in data:
    print row

 

python中mysql使用

标签:

原文地址:http://www.cnblogs.com/cfox/p/4498448.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!