python找不到数据库,如果脚本是从其他文件运行的
在评论中解决了
我与dataheavy项目进行了斗争。我可以运行一个使用查询文件的文件 - 查询和转换器在这里 - 没有问题,但是当我运行再次运行该文件的文件时,我会发现无法找到DB的错误。
so:
Queryfile() : No problem,
Queryfile() -> Actionfile() : No problem,
Queryfile() -> Actionfile() -> action_manager(): Error, cant find db,
Queryfile() -> Actionfile() -> action_manager() -> startupfile(): Giant error, no way to solve it.
我的目标是在主DIR中构建一个启动文件,并从那里触发所有需要的脚本,但是我不断收到此错误:
(sqlite3.OperationalError) unable to open database file
(Background on this error at: https://sqlalche.me/e/14/e3q8)
('ERROR_LOADING_ANALYSES', OperationalError('(sqlite3.OperationalError) unable to open database file'))
这确实很糟糕,我不知道我需要做什么才能进行此项目。如果有任何替代方法,例如将WorkDirectory移动到此文件,运行并返回,我想知道它。请让我知道您如何处理此问题。
这是我的项目树。
├───core_data
│ ├───data_temp
│ ├───**DATABASE**
├───core_update
│ ├───update_main
│ │ └───__pycache__
│ ├───update_additional_scripts
│ │ └───__pycache__
├───core_utils
│ ├───database_querys
│ │ └───__pycache__
│ ├───database_tables
│ │ └───__pycache__
├───startup file
├───constants.
期待您的答复。
Solved in comment
I have this struggle with a dataheavy project. I can run a file that uses a query file -- Al the query's and converters are in here -- without problems, but when I run a file that runs that file again, I get an error that the db cant be found.
so:
Queryfile() : No problem,
Queryfile() -> Actionfile() : No problem,
Queryfile() -> Actionfile() -> action_manager(): Error, cant find db,
Queryfile() -> Actionfile() -> action_manager() -> startupfile(): Giant error, no way to solve it.
My goal is to build a startup file in the main dir and trigger all needed scripts from there, but I constantly receive this error:
(sqlite3.OperationalError) unable to open database file
(Background on this error at: https://sqlalche.me/e/14/e3q8)
('ERROR_LOADING_ANALYSES', OperationalError('(sqlite3.OperationalError) unable to open database file'))
This is really bad and I don't know what i need to to make this project run. If there is any alternative way, for example move the workdirectory to this file, run it and move back, I would like to know it. Please let me know how you are dealing with this.
this is my project tree.
├───core_data
│ ├───data_temp
│ ├───**DATABASE**
├───core_update
│ ├───update_main
│ │ └───__pycache__
│ ├───update_additional_scripts
│ │ └───__pycache__
├───core_utils
│ ├───database_querys
│ │ └───__pycache__
│ ├───database_tables
│ │ └───__pycache__
├───startup file
├───constants.
Look forward to your reply.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决方案是将项目工作目录移至文件夹的开始以及进入系统路径的路径。
The solution is to move the project work directory to the start of you folder and at the paths to the system paths.
您可以通过使用python.toml文件(带有源文件“ src')构建软件包来解决此问题,以使用PIP Install -E安装软件包。在您的项目文件和您完成的数据中。
You can solve this by building a package with a python.toml file (with a source file 'src') install the package with pip install -e . in the dir of you project file and your done.