def main():
    database_url = os.environ.get("DATABASE_URL", None)
    engine = create_engine(database_url)
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        for post in get_posts():
            populate_db(post)
Beispiel #2
0
def main():
    database_url = os.environ.get('DATABASE_URL', None)
    engine = create_engine(database_url)
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        for entry in import_entries():
            populate_db(entry)
Beispiel #3
0
def sqlengine(request):
    engine = create_engine(TEST_DATABASE_URL)
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)

    def teardown():
        Base.metadata.drop_all(engine)

    request.addfinalizer(teardown)
    return engine
Beispiel #4
0
def dbtransaction(request, sqlengine):
    connection = sqlengine.connect()
    transaction = connection.begin()
    DBSession.configure(bind=connection, expire_on_commit=False)

    def teardown():
        transaction.rollback()
        connection.close()
        DBSession.remove()

    request.addfinalizer(teardown)
    return connection
def sqlengine(request):
    """Takes care of connection to DB."""
    engine = create_engine(TESTDB_URL)
    Base.metadata.create_all(engine)
    connection = engine.connect()
    DBSession.configure(bind=connection)

    def teardown():
        Base.metadata.drop_all(engine)

    request.addfinalizer(teardown)
    return connection
Beispiel #6
0
def sqlengine(request):
    """Takes care of connection to DB."""
    engine = create_engine(TESTDB_URL)
    Base.metadata.create_all(engine)
    connection = engine.connect()
    DBSession.configure(bind=connection)

    def teardown():
        Base.metadata.drop_all(engine)

    request.addfinalizer(teardown)
    return connection
Beispiel #7
0
def dbtransaction(request, sqlengine):
    connection = sqlengine.connect()
    transaction = connection.begin()
    DBSession.configure(bind=connection)
    entry = Entry(title="testing 1", text="this is a test")
    DBSession.add(entry)
    DBSession.flush()

    def teardown():
        transaction.rollback()
        connection.close()
        DBSession.remove()

    request.addfinalizer(teardown)

    return connection
Beispiel #8
0
def create_session():
    from sqlalchemy import create_engine
    database_url = os.environ.get('DATABASE_URL', None)
    engine = create_engine(database_url)
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)