是否可以使用Sqlite3数据库打包Python项目?
每次尝试将其全部打包时,脚本都找不到数据库文件。它因错误sqlite3.OperationalError: unable to open database file
这是我目前所拥有的。有人可以发现我缺少的东西或做错了吗?
文件结构
setup.cfg
setup.py
invoicing/
|__ __init__.py
|__ invoicing.py
|__ sqlite3/
|__ invoicing_live.db
|__ constants
|__ constants.py
setup.py
from setuptools import setup, find_packages
readme = open('README.md', 'r')
README_TEXT = readme.read()
readme.close()
setup(
name='project',
version='0.1.0',
description='Blah blah',
long_description_content_type='text/markdown',
entry_points={
'console_scripts': [
'project=project.__main__:main',
],
},
packages=find_packages(exclude=['contrib', 'docs', 'tests*']),
package_data={'project': 'sqlite3/*.db'},
python_requires='>=3.5',
)
constants.py
from pkg_resources import resource_filename
DB_PATH = resource_filename('project', '/sqlite3')
DB = DB_PATH + '/project_live.db'