我尝试在金字塔中创建一个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上运行。
答案 0 :(得分:2)
您需要在sqlite,postgres或任何其他数据库中创建数据库。此后转到development.ini
文件编辑sqlalchemy.url = sqlite:///%(here)s/MyProject.sqlite
并指定数据库的名称,然后运行initialize_myproject_db
development.ini
command。如果你使用的是mysql,那行应该是
sqlachemy.uri = mysql://用户名:密码@ host / dbname
答案 1 :(得分:2)
第一次尝试金字塔时,我遇到了同样的问题,经过多次命令组合后,我才得到解决方案。
从项目根目录运行命令:
initialize_tutorial_db development.ini
的信息
答案 2 :(得分:1)
它在第一点就说 - 你需要运行initialize_MyProject_db development.ini来创建数据库。
如果不是这样,请从运行服务器发布日志。