[英]How to use PostgreSQL on a Pyramid App in OpenShift?
How can I use a PostgreSQL database on a Pyramid application? 如何在Pyramid应用程序上使用PostgreSQL数据库? I'm using OpenShift as my "PaaS".
我将OpenShift用作“ PaaS”。
I added the PostgreSQL cartridge and it gave me a sql connection url that looked like this: 我添加了PostgreSQL墨盒,它为我提供了一个如下所示的sql连接url:
postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT
But I don't know how and where to use it. 但是我不知道如何以及在哪里使用它。
I solved it myself, by adding/replacing this to my "_ _init__.py" and "initializedb.py" 我自己解决了此问题,方法是将其添加/替换为“ _ _init__.py”和“ initializedb.py”
import os
engine = create_engine(os.environ.get('OPENSHIFT_POSTGRESQL_DB_URL'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.