Skip to content

Instantly share code, notes, and snippets.

@davidjb
Last active January 12, 2021 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidjb/643272824f469386f933e7a4e081a81e to your computer and use it in GitHub Desktop.
Save davidjb/643272824f469386f933e7a4e081a81e to your computer and use it in GitHub Desktop.
Installation of local database servers via Docker and test running with Django and Wagtail
# Any pip/python commands should be run in a virtualenv or adapted for pipenv etc
# System-level installation commands are for Mac but are adaptable to Linux
# SQLite
# Requires Python to be built with sqlite3 support. This may require installation of
# a separate package such as `py39-sqlite3` on FreeBSD but most OSes have this support
# built in as of 2020.
DATABASE_ENGINE=django.db.backends.sqlite3 DATABASE_NAME=:memory: python runtests.py
# Postgres
docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres
pip install psycopg2
PGUSER=postgres PGPASSWORD=mysecretpassword PGHOST=localhost PGPORT=5432 python runtests.py --postgres
# MySQL
# Requires Python patched with https://bugs.python.org/issue42504 for macOS 11 / Python 3
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mysecretpw -d mysql:latest
brew install mysql-client
pip install mysqlclient
DATABASE_ENGINE=django.db.backends.mysql DATABASE_HOST=127.0.0.1 DATABASE_PORT=3306 DATABASE_USER=root DATABASE_PASSWORD=mysecretpw python runtests.py
# Microsoft SQL Server
# Further config for pyodbc (dependency of django-mssql-backend)
# may be required; see https://github.com/mkleehammer/pyodbc/wiki
# for details of different OSes and system-level configuration
docker run --name sqlserver -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
pip install -e git+https://github.com/ESSolutions/django-mssql-backend.git#egg=django-mssql-backend
brew install freetds unixodbc
DATABASE_ENGINE=sql_server.pyodbc DATABASE_DRIVER=FreeTDS DATABASE_HOST=localhost DATABASE_PORT=1433 DATABASE_USER=sa DATABASE_PASSWORD='yourStrong(!)Password' python runtests.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment