[英]python 2.4.3 sqlite executemany syntax
I am stuck using python 2.4.3 and the sqlite module issued with that distribution. 我被困在使用python 2.4.3和该发行版发布的sqlite模块中。
How can i run the executemany command in this environment? 如何在这种环境中运行executemany命令? The more modern syntax seems to have an issue. 更现代的语法似乎有问题。
import sqlite as sql
conn = sql.connect('test.db')
c = conn.cursor()
c.execute('''create table test(item text)''')
list = ['apple', 'orange', 'banana']
c.executemany('''insert into test values(?)''', list)
Python 2.4.3 is quite old I guess and I can't find any docs, and I have no assoicated doc string associated with the executemany function. 我猜Python 2.4.3很老了,我找不到任何文档,也没有与executemany函数关联的关联文档字符串。
I appreaciate the help. 我感谢您的帮助。
You should use %s
instead of ?
您应该使用%s
而不是?
: :
import sqlite as sql
conn = sql.connect('test.db')
c = conn.cursor()
c.execute('''create table test(item text)''')
list = ['apple', 'orange', 'banana']
c.executemany('''insert into test values(%s)''', list)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.