4

我试图在金字塔中创建一个 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机器上运行。

4

3 回答 3

2

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

于 2014-08-15T13:33:18.247 回答
2

第一次尝试Pyramid,我也遇到了同样的问题,经过多次命令组合,我才得到了解决方案。

项目 root运行,命令:

initialize_tutorial_db development.ini

信息取自Wiki2 SQLAlchemy 教程

于 2014-09-08T14:18:28.650 回答
1

它在第一点就说 - 你需要运行 initialize_MyProject_db development.ini 来创建数据库。
如果不是这种情况,请发布运行服务器的日志。

于 2013-11-14T17:04:09.353 回答