def db(): db = SqliteDatabase(':memory:') with db: Story.bind(db) Story.create_table() yield db Story.drop_table()
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)