Sqlite插入结果不会显示在下一个立即选择命令中

2024-04-26 17:22:04 发布

您现在位置:Python中文网/ 问答频道 /正文

cur = self.db.execute("insert into HiddenNode%d (createKey) values ('%s')" % (i, preNewNode))
print 'Added new node in HiddenNode%d: %s' % (i, preNewNode)
self.db.commit()

test = self.db.execute("select * from HiddenNode2").fetchall()[0]
print test

此代码生成如下输出:

Added new node in HiddenNode2: 1_2_3
!!!!!
(u'1_2',)

看来插入根本没有发生。但在通话结束后。它将所有更改提交到数据库。在连接到数据库时,我指定隔离级别为'IMMEDIATE',并将auto commit设置为true。你知道吗

相关问题在here中。但我两种答案都试过了。没有人能解决我这边的问题。你知道吗

有什么办法能让手术后插入物马上出现吗?你知道吗


Tags: intestself数据库nodeaddednewexecute