window 下的sqlite3 数据库文件复制到linux下的坑
1.有时候在window中本地写好的代码,和数据库文件要迁移到liunx系统下,需注意的点:
Window下的sqlite3 数据库复制到liunx 下后,在运行python 代码时报 : no such table
需要注意的是Window下的sqlite3 的数据文件是有后缀名:.db
而linux 下的sqlite3 数据库文件没有后缀名
window 下的sqlite3 数据库文件有后缀名.db
而linux 下的sqlite3 数据库文件没有后缀名
2.Use an absolute path for your database file. You can base it on the absolute path of your script:
import os.path
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
db_path = os.path.join(BASE_DIR, "PupilPremiumTable.db")
with sqlite3.connect(db_path) as db:
使用绝对路径去找sqlite3文件
https://stackoverflow.com/questions/28126140/python-sqlite3-operationalerror-no-such-table