【问题标题】:Python3 | sqlite3: executemany() inserts nothingPython3 | sqlite3:executemany() 不插入任何内容
【发布时间】:2015-12-04 03:53:33
【问题描述】:

我正在尝试使用sqlite3executemany() 插入带有Python3 的多个值。

代码:

import sqlite3
conn = sqlite3.connect('rssnewsdata.db')
c = conn.cursor()

entries = [
    ('url1', 1234, 'title1', 'summary1', 'feedurl1'),
    ('url2', 1235, 'title2', 'summary2', 'feedurl2'),
    ('url3', 1236, 'title3', 'summary3', 'feedurl3'),
    ('url4', 1237, 'title4', 'summary4', 'feedurl4')
]

c.executemany('INSERT INTO entries VALUES (?, ?, ?, ?, ?)', entries)

db 文件存在,表存在,我可以从中使用Python3SELECT,所以连接到它不是问题。这些列是TEXTINTEGERTEXTTEXTTEXT 类型。

Python 没有报告错误。缺什么?

【问题讨论】:

    标签: python-3.x sqlite sql-insert executemany


    【解决方案1】:

    你需要

    conn.commit()
    

    插入之后。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-19
      • 1970-01-01
      • 2021-03-24
      • 2015-07-27
      • 2017-10-20
      • 2012-10-02
      • 2018-02-15
      • 2011-01-13
      相关资源
      最近更新 更多