gpt4 book ai didi

python - Pyramid 中的数据库配置

转载 作者:太空狗 更新时间:2023-10-30 02:46:33 26 4
gpt4 key购买 nike

我试图在 Pyramid 中创建一个 sqlalchemy 项目,当我运行服务器时,我得到这个错误,

Pyramid is having a problem using your SQL database.  The problem
might be caused by one of the following things:

1. You may need to run the "initialize_MyProject_db" script
to initialize your database tables. Check your virtual
environment's "bin" directory for this script and try to run it.

2. Your database server may not be running. Check that the
database server referred to by the "sqlalchemy.url" setting in
your "development.ini" file is running.

After you fix the problem, please restart the Pyramid application to
try it again.

当我检查我的 development.ini 文件时,sqlite 数据库是这样配置的,

sqlalchemy.url = sqlite:///%(here)s/MyProject.sqlite

这里需要更改什么才能正确配置它?

我在 linux box 上运行。

最佳答案

您需要在 sqlite、postgres 或任何其他数据库中创建一个数据库,然后转到 development.ini 文件编辑 sqlalchemy.url = sqlite:///%(此处) s/MyProject.sqlite 并指定数据库的名称,然后运行 ​​initialize_myproject_db development.ini 命令。如果您使用的是 mysql,该行应该是 sqlachemy.uri = mysql://用户名:密码@主机/数据库名

关于python - Pyramid 中的数据库配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19983268/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com