Search code examples
pythonpostgresqlopenshiftpyramid

How to use PostgreSQL on a Pyramid App in OpenShift?


How can I use a PostgreSQL database on a Pyramid application? I'm using OpenShift as my "PaaS".

I added the PostgreSQL cartridge and it gave me a sql connection url that looked like this:

postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT

But I don't know how and where to use it.


Solution

  • I solved it myself, by adding/replacing this to my "_ _init__.py" and "initializedb.py"

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