Skip to content

pythongosssss/sqlalchemy-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published