<s> from sqlalchemy . engine import create_engine <EOL> from sqlalchemy . orm import scoped_session , create_session <EOL> from sqlalchemy . ext . declarative import declarative_base <EOL> engine = None <EOL> db_session = scoped_session ( lambda : create_session ( bind = engine , <EOL> autoflush = False , autocommit = False , expire_on_commit = False ) ) <EOL> Base = declarative_base ( ) <EOL> Base . query = db_session . query_property ( ) <EOL> def init_engine ( uri , ** kwargs ) : <EOL> global engine <EOL> engine = create_engine ( uri , ** kwargs ) <EOL> Base . metadata . create_all ( bind = engine ) <EOL> return engine </s>
