如何在 OpenShift 中的金字塔应用程序上使用 PostgreSQL?

How to use PostgreSQL on a Pyramid App in OpenShift?

如何在 Pyramid 应用程序上使用 PostgreSQL 数据库?我正在使用 OpenShift 作为我的 "PaaS".

我添加了 PostgreSQL 盒式磁带,它给了我一个 sql 连接 url,看起来像这样:

postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT

但我不知道如何以及在哪里使用它。

我自己解决了,通过 adding/replacing this to my "_ _init__.py" and "initializedb.py"

import os
engine = create_engine(os.environ.get('OPENSHIFT_POSTGRESQL_DB_URL'))