Skip to content

Create PostgreSQL database on Render

This starter-kit only uses a remote PostgreSQL database on Render. The reason is that we want to move faster than normal projects and setting up a local PostgreSQL database can be full of headaches based on different system configuration and comes with extra complexity in terms of keeping the local database in sync with the remote one.

The only major disadvantage in using this remote-only approach is that you will not be able to make database updates if you don't have an internet connection. So if this is really important for your use-case, you might consider setting up a local database.

Note: for initial testing purposes you can create a free database on Render, but it will expire in about a month and all your data will be lost if you don't upgrade to a paid plan, which starts at $6 a month.

Steps in the Render UI:

  1. Create an account at render.com if you haven’t done so yet.
  2. Go to your dashboard, click on the Add new button and in the dropdown menu select Postgres.
  3. In the form which comes up, fill in all the required fields, select the free plan and then click Create Database.
  4. Once the database is created, click on the Connect button and copy the external database URL.

Open your local .env file (where your secret environment variables are stored) and add the database URL to the RENDER_DB_URL variable.

Your .env file should look like this:

Open your local .env file (where your secret environment variables are stored) and add the database URL to the RENDER_DB_URL variable.

RENDER_DB_URL="your-render-postgres-external-url"

Note: Before restarting your app, run the Flask database upgrade command again:

flask db upgrade

Then run you app and verify all is working:

flask run -p 5001

If you want to download a copy of the PostgreSQL database onto your local machine, run this command with the pg_dump utility:

pg_dump -Fc -v -d [RENDER_POSTGRES_URL] --schema=public -f render_dump.bak