python sqlite3.connect-无法打开数据库文件

过度

我在Mac上运行Python3,以测试简单的sql数据库。我有以下代码

import sqlite3

# connecting to the database
connection = sqlite3.connect("myTable.db")
crsr = connection.cursor()

# SQL command to create a table in the database
sql_command = """CREATE TABLE emp (
staff_number INTEGER PRIMARY KEY,
fname VARCHAR(20),
lname VARCHAR(30),
gender CHAR(1),
joining DATE);"""

# execute the statement
crsr.execute(sql_command)

# SQL command to insert the data in the table
sql_command = """INSERT INTO emp VALUES (23, "Rishabh", "Bansal", "M", "2014-03-28");"""
crsr.execute(sql_command)

crsr.execute(sql_command)
connection.commit()
connection.close()

运行此代码时,出现错误:

Traceback (most recent call last):
  File "test.py", line 8, in <module>
    connection = sqlite3.connect("myTable.db")
sqlite3.OperationalError: unable to open database file

我想念什么?我试图取代("myTable.db")(".myTable.db")("./myTable.db"),但同样的问题。请提出建议。

莫尔斯

更改对SQLite数据库文件的权限。

的Ubuntu

sudo chmod 775 /FolderOfSQLiteDBfile/
sudo chmod 664 /FolderOfSQLiteDBfile/sqlite.db

视窗

chmod 775 /FolderOfSQLiteDBfile/

请参阅:sqlite错误无法打开数据库文件

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法使用 python 访问 sqlite3 数据库文件

SQLite3,OperationalError:无法打开数据库文件

sqlite3无法打开数据库文件,运行Centos,flask uwsgi nginx

令人困惑的Django sqlite3“无法打开数据库文件”错误

IronPython SQLite3 OperationalError:无法打开数据库文件

从Python以只读模式打开sqlite3数据库

SQLite-无法打开数据库文件

Python数据库sqlite3

如何将现有的数据库文件加载到Python sqlite3中的内存中?

Django - gitlab-ci - sqlite3 - django.db.utils.OperationalError:无法打开数据库文件

无法打开 sqlite 数据库,指定目录或数据库文件不存在

sqlite3.OperationalError:无法打开数据库文件

sqlite3.OperationalError:无法打开数据库文件

无法在golang中打开SQLite数据库:“无法打开数据库文件[已恢复]”-错误

Python Sqlite3 附加到内存数据库

在Python中从sqlite3数据库写入CSV

python sqlite3从excel创建数据库

Sqlite3数据库Python条件语句

带python的sqlite3数据库避免重复

Python Sqlite3数据库表未更新

Python SQLite3 数据库查询绑定错误

无法从UWP应用的本地数据存储中打开SQLite数据库文件

放置在网络文件夹中时,无法打开SQLite数据库文件

无法在sqlite中打开数据库文件(使用finisar.sqlite)

Microsoft.Data.Sqlite.SqliteException:'SQLite错误14:'无法打开数据库文件'。

如何打开位于 sqlite3 中特定文件夹中的数据库文件?

SQLite未捕获的PDOException-无法打开数据库文件

SQLite错误代码:14,“无法打开数据库文件”

为什么我的SQLite表上显示“无法打开数据库文件”?