def create_tables(client): return tables.create_all(client)
def __create(args): print('--- Creating tables ---') pprint.pprint(tables.create_all(args.client), indent=2)
from random import randint import datetime from sqlalchemy import create_engine, select, func from sqlalchemy.engine.url import URL import settings import utils import tables engine = create_engine(URL(**settings.DATABASE)) tables.create_all(engine) data = utils.get_static_data() with engine.begin() as conn: for book in data['books']: ins = tables.Book.insert().values(title=book) conn.execute(ins) ins = tables.Person.insert() values = [] for person in data['persons']: dob = utils.get_dob(1980, 2010) values.append({'name': person, 'date_of_birth': dob}) with engine.begin() as conn: conn.execute(ins, values) ins = tables.Write.insert() with engine.begin() as conn: