Skip to content

Instantly share code, notes, and snippets.

@groner
Created August 19, 2010 00:22
Show Gist options
  • Select an option

  • Save groner/536636 to your computer and use it in GitHub Desktop.

Select an option

Save groner/536636 to your computer and use it in GitHub Desktop.
from sqlalchemy import create_engine
import db
def load_config():
return { 'dburi': 'sqlite:foobar.sqlite' }
if __name__ == '__main__':
config = load_config()
engine = create_engine(config['dburi'])
db.init_model(engine)
# Do some stuff...
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base
Session = scoped_session(sessionmaker())
class _Base(object):
query = Session.query_property()
Base = declarative_base(cls=_Base)
def init_model(engine):
Session.configure(bind=engine)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment