Repository navigation
Databases
A database is recorded by its schema and every row; row order is free.
Name the file in databases (see Project Settings): a file in the data folder, or, with
isolate=True, a file inside the app such as database/app.sqlite. init finds SQLite files and Laravel's
DB_CONNECTION=sqlite by itself.
Give each run the same starting data in setup and return the tables from snapshot. parityrun.snapshot.dbapi
reads any DB-API connection: columns as [name, type, nullable, default, key], every row, decimals and times as
text, bytes by hash.
import contextlib, subprocess
import pymysql
from parityrun.snapshot import dbapi
def connect():
return pymysql.connect(host="127.0.0.1", user="shop", password="shop", database="shop_test")
def setup(run):
subprocess.run("mysql -ushop -pshop shop_test < fixtures/start.sql", shell=True, check=True)
def snapshot(run):
with contextlib.closing(connect()) as conn:
return dbapi(conn, "mysql", skip={"migrations"})Then in the project: PROJECT = Project(..., setup=setup, snapshot=snapshot). init notes a MySQL or PostgreSQL
database it finds in .env in parityrun_project.py, for you to fill in.
parityrun is MIT-licensed. Install: pip install parityrun. Issues and source: github.com/arttujan/parityrun.
Start
Porting
Reference
Links