- set up your python (virtual) environment
install sqlalchemy and sqlalchemy-migrate, you will also need psychopg
pip install SQLAlchemy sqlalchemy-migrate
sudo apt-get install python-psycopg2
- startup PostgreSQL with Vagrant
vagrant up
this will startup a virtual machine based on ubuntu/trusty64, update it and set up the latest PostgreSQL based on PostgreSQL-s Vagrantfile
The output of vagrant up (--provision) will print you how to access the database from CLI, in the python code this has been already set up.
- put the database under version control
python manage.py version_control
this will initialize version control over the schema (migrate_version table)
- test the change script
python manage.py test
- upgrade to the latest version
python manage.py upgrade
0 -> 1...
done
This repo only contains a set of python scripts that i experiment with while getting started with sqlAlchemy and db Schema versioning with PostgreSQL.
- The Vagrantfile is the PostgreSQL provided virtualized PostgreSQL setup for development.
- sql_alchemy folder is the db schema versioning rumblings stuff based on this tutorial
- sqlalchemy*.py_ scripts are simple sample scripts playing with the declarative system, nothing to do with the sql_alchemy repo from the tutorial