I'm currently trying to develop a simple python web application on Heroku and I'm trying to connect to the Heroku Postgres database. I've managed to connect, but only through using the database url Heroku provides:
from flask import Flask
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
app = Flask(__name__)
engine = create_engine('postgres://[email protected]:XXX')
Base = declarative_base()
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()
Is there a way to connect to the Heroku database through my python code without having to include the exact url? Thanks!