Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#пока ненужный файл для тестов
import asyncio
from aiopg.sa import create_engine
import sqlalchemy as sa
metadata = sa.MetaData()
users = sa.Table('users',metadata,
sa.Column('id',sa.Integer,primary_key=True),
sa.Column('name',sa.String(255)),
sa.Column('date',sa.Date),
sa.Column('tag',sa.String(255))
)
async def create_tables(conn):
await conn.execute('''CREATE TABLE users (
id serial PRIMARY KEY,
name varchar(255),
birthday timestamp)''')
async def go():
engine = await create_engine(user='user',
database='users_db',
host='127.0.0.1',
password='1234')
async with engine:
async with engine.acquire() as conn:
await create_tables(conn)
loop = asyncio.get_event_loop()
loop.run_until_complete(go())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment