Skip to content

Latest commit

 

History

History
38 lines (23 loc) · 732 Bytes

File metadata and controls

38 lines (23 loc) · 732 Bytes

Sample sqlalchemy project showing simple usage, schema migration and data migration.

Setup

Create virtual environment
python -m venv venv

Activate virtual environment
venv\Scripts\activate (Windows)
source venv/bin/activate (Linux/MacOS)

Install dependencies
pip install -r requirements.txt

Running

python main.py

Altering the database

Update db/models.py to e.g. add new column

Generate a new migration
alembic revision --autogenerate -m "your message"

Test upgrade

alembic upgrade head or running main.py will do this automatically if required

Downgrade

alembic downgrade -1

Reset migration/database

Delete alembic/versions/*
Delete testdb.db
Generate a new migration