【发布时间】:2010-01-25 06:37:23
【问题描述】:
我之前也问过类似的问题,这里是我想要达到的目标的详细解释
我有两个 sqlite 表
table1 - 是标准表 - 具有 server、id、status 等字段
table2 - 有 server,id,status,number,logfile 等字段
Table2 为空,Table1 有值。我正在尝试用 table1 中的条目填充 table2。 我可以从 table1 检索记录,但是在尝试插入 table2 时它失败了。(但插入单个字段有效)
self.cursor.execute("select * from server_table1 limit (?)",t)
#insert into server_process
for record in self.server_pool_list:
print "--->",record # geting output like ---> (u'cloud_sys1', u'free', u'192.168.1.111')
self.cursor.execute("insert into server_table2(server,status,id) values (?,?,?)",(record[0],)(record[1],),(record[2],));
还告诉我如何在插入失败时生成更有用的错误消息
【问题讨论】:
-
复制并粘贴生成的错误。
-
是的..谢谢我解决了。我应该使用这个 (?,?,?"),(record[0],record[1],record[2],) 而不是上面...现在它正在工作:)