Skip to content

Using different postgres user for application db request and migration #538

Discussion options

You must be logged in to vote

First of all, it is a very bad idea to enter credentials directly in the code. You should import your database URL from an environment variable:

api.config['SQLALCHEMY_DATABASE_URI'] =  os.environ['DATABASE_URL']

And now that you have an environment variable, you can set it to different values depending on your needs. When using Flask-Migrate you can set DATABASE_URL to your admin credentials, and when using the web app you can set your regular user's URL.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mikebionic
Comment options

@CANEVETGASPARD
Comment options

Answer selected by CANEVETGASPARD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants