python sqlite3插入仅在控制台中起作用
我在sqlite3中有一个简单的插入语句,但是python版本不起作用,但同一语句在控制台中效果很好。 Python没有显示任何插入错误。关于如何在Python中修复此插入语句的任何建议吗?
插入语句:
插入设施(facitial_id,facity_name)值('239Sie39','大厅A');
表创建语句:
创建表格(如果不存在)(ID Integer主密钥自动启动唯一唯一唯一) ,facity_id,facity_name)
函数存储数据:
def store_data(table_name: str, rec: dict):
keys = ','.join(rec.keys())
values = tuple(rec.values())
stmt = f"INSERT INTO {table_name} ({keys}) VALUES {values}"
cur.execute(stmt)
I have a simple insert statement in sqlite3, but somehow the python version doesn't work, but the exact same statement works fine in console. And python doesn't show any insert error. Any suggestion on how to fix this insert statement in python?
Insert statement:
INSERT INTO facilities (facility_id,facility_name) VALUES ('239SIE39', 'Lobby A');
Table creation statement:
CREATE TABLE IF NOT EXISTS facilities (id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, facility_id, facility_name)
Function to store data:
def store_data(table_name: str, rec: dict):
keys = ','.join(rec.keys())
values = tuple(rec.values())
stmt = f"INSERT INTO {table_name} ({keys}) VALUES {values}"
cur.execute(stmt)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论