Skip to content

Instantly share code, notes, and snippets.

@EgorOmelyanenko
Created March 23, 2017 19:10
Show Gist options
  • Save EgorOmelyanenko/e7a8244ee48bcf713ed64f805f8e56b6 to your computer and use it in GitHub Desktop.
Save EgorOmelyanenko/e7a8244ee48bcf713ed64f805f8e56b6 to your computer and use it in GitHub Desktop.
#пока ненужный файл для тестов
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