python 连接 mysql
新手求指导
MySQLdb已经装上了
下面是代码
- Python code
#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()
运行后 显示n为1
以下是运行后控制台输出:
pydev debugger: starting
1
连接字符串 应该没问题 ,用过它建表(python建表成功)
没有加约束,外键什么的
[解决办法]
给你来添个人气。 好运
[解决办法]
都没看到你的问题的是什么。
[解决办法]
他的问就是插入了..为啥没有怀上,因为没有射!