[pydal] Connect to Heroku Database

16 views
Skip to first unread message

Carlos Zenteno

unread,
Jul 21, 2020, 2:20:20 PM7/21/20
to web2py-users
Has anybody been able to connect to a Postgres database
using stand alone Pydal?

I know I have to pass the database credentials via the environment
variable DATABASE_URL thru the heroku-cli like this:

DATABASE_URL=$(heroku config:get DATABASE_URL -a books-proyecto1) MY-PROCESS

but I don't know what is MY-PROCESS (books-proyecto1 is MY-APP).

Then I just call DATABASE_URL in my app to make the connection.

import os
import psycopg2
from bottle import run, route, request, post, get
from yatl import *
from pydal import *

DATABASE_URL = os.environ['DATABASE_URL']
db = DAL('DATABASE_URL')

When I run the app it gives me a KeyError, beacause DATABASE_URL is empty.
How do I pass DATABASE_URL from Heroku to PyDAL?
I think the key is MY-PROCESS.
Reply all
Reply to author
Forward
0 new messages