python 连接 mysql
新手求指导
MySQLdb已经装上了
下面是代码
#coding=utf-8'''Created on 2011-10-25@author: admin'''import MySQLdb #建立和数据库系统的连接 conn = MySQLdb.connect(host='localhost', user='root', passwd='333333') #选择数据库 conn.select_db('python');#获取操作游标 cursor = conn.cursor()#value = [1, "inserted"];#插入一条记录 sql = "insert into test values(%s,%s)"param = (1, "inserted")n = cursor.execute(sql, param)print ncursor.close(); conn.close()