clwn.net
当前位置:首页 >> Cur.ExECutE >>

Cur.ExECutE

推荐方式一: cur.execute(“select count(*) from table_name where aaa=:1 and bbb=:2″,(1234,’test’)) 推荐方式二: cur.execute(“select count(*) from table_name where aaa=:x and bbb=:y”,x=1234,y=’test’)

需要改成:resultcur.execute("insert into dashboard values(%f,%f,%f)" % (x,y,z))x是变量,不能直接放在字符串中

一般的处理思路是将数据库操作的方法放在一个模块中,比如ConnectSQL.py: import MySQLdbdef ExecNonQuery(sql): conn = MySQLdb.connect(host='xxxx',...

cur变量你没有赋值就用了啊,数据库如果是mysql的话,应该这样吧: db = MySQLdb.connect("localhost","root","123456","myciti" )cur = db.cursor()

格式化字符串用法实例: str = "%s is a %s" % ('fish', 'food') 题主把‘%’写成','了。

SQL语句写的不对,cur.executemany("insert into test(name,age) values ('"+values[person_a]+"','"+values[person_b]+"')")

应为这样吧 cur.execute("INSERT INTO athomes(temperature) VALUES(‘“+value1+”’)")

cur.execute('select * from user') conn.commit() cur.close() conn.close()except MySQLdb.Error,e: print "Mysql Error %d: %s" % (e.args[0], e...

sql = "insert into haha(pid text,name text,age text,duiwu text) values('%s','%s','%s','%s')" 试试

请给出具体的报错信息 根据报错行号,给出其附近的代码

网站首页 | 网站地图
All rights reserved Powered by www.clwn.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com