window 下的sqlite3 數(shù)據(jù)庫文件復(fù)制到linux下的坑
1.有時(shí)候在window中本地寫好的代碼贡茅,和數(shù)據(jù)庫文件要遷移到liunx系統(tǒng)下承桥,需注意的點(diǎn):
?Window下的sqlite3 數(shù)據(jù)庫復(fù)制到liunx 下后,在運(yùn)行python 代碼時(shí)報(bào) : no such table
需要注意的是Window下的sqlite3 的數(shù)據(jù)文件是有后綴名:.db
而linux 下的sqlite3 數(shù)據(jù)庫文件沒有后綴名
window 下的sqlite3 數(shù)據(jù)庫文件有后綴名.db
而linux 下的sqlite3 數(shù)據(jù)庫文件沒有后綴名
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