evertap
Frameworks

Django

Use an evertap PostgreSQL or MySQL database with Django, with DATABASES from the URL, migrations, and test databases, parallel ones included.

Each evertap database runs on a PostgreSQL or MySQL instance of its own, and the user in its URL can create and drop databases there. manage.py test creates its test databases as it does on a database you run yourself, --parallel included.

Create the database

evertap create postgres myapp     # or: evertap create mysql myapp
evertap env myapp >> .env

.env gains the URL:

DATABASE_URL=postgres://evertap_k3x9q2m7v1ab:…@ev.internal:5432/evertap_k3x9q2m7v1ab

On a laptop that reaches evertap on another machine, keep evertap connect running while you work (Connect from your laptop).

Read the URL in settings

Django does not read .env or URLs by itself. python-dotenv loads the file, and dj-database-url turns the URL into DATABASES:

pip install python-dotenv dj-database-url "psycopg[binary]"   # mysqlclient for MySQL

In settings.py:

import dj_database_url
from dotenv import load_dotenv

load_dotenv()

DATABASES = {
    "default": dj_database_url.config(conn_max_age=1800, conn_health_checks=True),
}

conn_max_age keeps a connection for up to 30 minutes, and conn_health_checks checks it before each request, since a connection through evertap connect can drop when evertap restarts or your network changes (Connection pools).

Migrate and test

python manage.py migrate
python manage.py test
python manage.py test --parallel 4

test creates test_ and your database's name, such as test_evertap_k3x9q2m7v1ab, on the same instance and drops it at the end; --keepdb keeps it for the next run. --parallel makes a copy for each process. On MySQL, Django copies it with the mysqldump and mysql commands, so install them first.

Good to know

  • evertap does not offer PostgreSQL's own TLS. Leave sslmode out of the URL, or set it to disable; sslmode=require fails.
Edit on GitHub

The evertap name and logo are not licensed with the code (section 6 of the license). You may use them to refer to evertap, but not to name or brand your own product or service, or in a way that suggests evertap made or endorses it, without permission.

evertap is an independent project. It is not affiliated with, endorsed, sponsored, supported, or certified by the owners of the software it runs, and it uses their names only to say which software that is.

  • Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.
  • MySQL is a registered trademark of Oracle and/or its affiliates.
  • Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd.
  • Other names, including Garage and Cloudflare, may be trademarks of their respective owners.

On this page