SQLite python 不更新表 [英] SQLite python does not update table

查看:28
本文介绍了SQLite python 不更新表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

import sqlite3

con = sqlite3.connect("testDB")
cur = con.cursor()

#cur.execute('CREATE TABLE test_table (id integer primary key, data text)')
cur.execute('INSERT INTO test_table VALUES (?, ?)', (76, 'MyData'))

当我运行此脚本时,它不会更新表.但是当我在 Linux 中使用 sqlite3 命令行执行相同的插入时,它会更新.为什么会这样或我做错了什么?

when I run this script it does not update table. But when I do the same insertion using sqlite3 commandline in Linux, it updates. Why is it so or there anything I am making wrong?

推荐答案

# Save (commit) the changes
con.commit()

这篇关于SQLite python 不更新表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆