Skip to content

Instantly share code, notes, and snippets.

@clutchski
Created November 24, 2009 00:52
Show Gist options
  • Save clutchski/241527 to your computer and use it in GitHub Desktop.
Save clutchski/241527 to your computer and use it in GitHub Desktop.
"""
A Caribou migration demonstrating an interface for database agnostic migrations
that doesn't force how you connect to the database.
"""
def upgrade(connector):
# a connector can give you a plain old db api connection
conn = connector.connect()
conn.execute("create table my_table ...")
# or maybe you want to connect with your favorite ORM
# like sqlalchemy or storm
url = connector.get_sqlachemy_url()
sqlalchemy.create_engine(url)
# or perhaps you want to do something all to yourself
user = connector.user
password = connector.user
do_something(user, password)
def downgrade(connector):
# same idea here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment