Created
August 19, 2010 00:22
-
-
Save groner/536636 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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