python sqlite3.erationalerror:无法打开数据库文件
我正在尝试使用python和sqlite 3使用下面的代码在PC上创建数据库,但是当我尝试运行时,我会得到这个错误
conn = sqlite3.connect('test_database')
sqlite3.OperationalError: unable to open database file
,我是新手,很抱歉,如果这是一个简单的错误,我很抱歉。有人可以告诉我如何解决这个问题吗?
import sqlite3
conn = sqlite3.connect('test_database')
c = conn.cursor()
c.execute('''
CREATE TABLE IF NOT EXISTS bot_memory
([id] INTEGER PRIMARY KEY, [dateandtime] datetime, [task] varchar, [result] varchar)
''')
conn.commit()
conn.close()
I am trying to create a Database on my PC using python and SQLite 3 using the code below, however when I attempt to run I get this error
conn = sqlite3.connect('test_database')
sqlite3.OperationalError: unable to open database file
I'm quite new to this, so sorry if this is a simple mistake. Could someone tell me how i can fix this?
import sqlite3
conn = sqlite3.connect('test_database')
c = conn.cursor()
c.execute('''
CREATE TABLE IF NOT EXISTS bot_memory
([id] INTEGER PRIMARY KEY, [dateandtime] datetime, [task] varchar, [result] varchar)
''')
conn.commit()
conn.close()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是我需要安装 sqlite 和 sqlite Studio 。然后,我可以在PC上创建和管理数据库。
The problem was I needed to install SQLite and SQLite Studio. Then, I can create and manage the Databases on my pc.