Ejemplo n.º 1
0
def db():
    db = SqliteDatabase(':memory:')
    with db:
        Story.bind(db)
        Story.create_table()
        yield db
        Story.drop_table()
Ejemplo n.º 2
0
def main():
    path = Path(__file__).parent.parent / 'data' / 'stories.yml'
    records = [record.data for record in load(path.read_text(), schema)]

    with db:
        Story.drop_table()
        Story.create_table()

        for record in records:
            Story.create(**record)