def sqlengine(request, config): engine = create_engine(config.DATABASE_URL) session.configure(bind=engine) Model.metadata.create_all(engine) def teardown(): Model.metadata.drop_all(engine) request.addfinalizer(teardown) return engine
def dbtransaction(request, sqlengine): connection = sqlengine.connect() transaction = connection.begin() session.configure(bind=connection) def teardown(): transaction.rollback() connection.close() session.remove() request.addfinalizer(teardown) return session