PageRenderTime 22ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/shabti/templates/default/+package+/model/meta.py_tmpl

https://bitbucket.org/gawel/shabti
Unknown | 27 lines | 21 code | 6 blank | 0 comment | 0 complexity | 132437dafca607df645c3b75a5f62943 MD5 | raw file
 1{{if sqlalchemy}}
 2"""SQLAlchemy Metadata and Session object"""
 3from sqlalchemy import MetaData
 4from sqlalchemy.orm import sessionmaker, scoped_session
 5
 6__all__ = ['Session', 'metadata']
 7
 8# SQLAlchemy database engine.  Updated by model.init_model()
 9engine = None
10
11# Ready for SQLA 0.5 where autoflush defaults to True
12# and autocommit defaults to False (see SQLA sessionmaker 
13# docs for details of alternative configurations)
14
15# SQLAlchemy session manager.  Updated by model.init_model()
16import sqlalchemy
17if sqlalchemy.__version__ > '0.5':
18    Session = scoped_session(sessionmaker())
19else:
20    Session = scoped_session(sessionmaker(autoflush=True, transactional=True))
21
22# Global metadata. If you have multiple databases with overlapping table
23# names, you'll need a metadata for each database
24metadata = MetaData()
25
26# --- Overwritten by Shabti template
27{{endif}}