python找不到数据库,如果脚本是从其他文件运行的

发布于 2025-01-26 15:43:59 字数 1178 浏览 2 评论 0原文

在评论中解决了

我与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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一江春梦 2025-02-02 15:43:59

解决方案是将项目工作目录移至文件夹的开始以及进入系统路径的路径。

The solution is to move the project work directory to the start of you folder and at the paths to the system paths.

云巢 2025-02-02 15:43:59

您可以通过使用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文