import aiopg.sa import sqlalchemy as sa from sanic_study.main import app meta = sa.MetaData() question = sa.Table( 'question', meta, sa.Column('id', sa.Integer, nullable=False), sa.Column('question_text', sa.String(200), nullable=False), sa.Column('pub_date', sa.Date, nullable=False), sa.PrimaryKeyConstraint('id', name='question_id_pkey') ) choice = sa.Table( 'choice', meta, sa.Column('id', sa.Integer, nullable=False), sa.Column('question_id', sa.Integer, nullable=False), sa.Column('choice_text', sa.String(200), nullable=False), sa.Column('votes', sa.Integer, server_default="0", nullable=False), sa.PrimaryKeyConstraint('id', name='choice_id_pkey'), sa.ForeignKeyConstraint(['question_id'], [question.c.id], name='choice_question_id_fkey', ondelete='CASCADE') ) async def init_pg(app):
import aiopg.sa import sqlalchemy as sa from chat.settings import config meta = sa.MetaData() chat_user = sa.Table( 'chat_user', meta, sa.Column('id', sa.Integer, primary_key=True), sa.Column('username', sa.String(64), nullable=False), sa.Column('password', sa.String(200), nullable=False), sa.PrimaryKeyConstraint('id', name='chat_user_id_pkey') ) chat = sa.Table( 'chat', meta, sa.Column('id', sa.Integer, primary_key=True, autoincrement=True), sa.Column('name', sa.String(64), nullable=False, unique=True), sa.PrimaryKeyConstraint('id', name='chat_id_pkey') ) message = sa.Table( 'message', meta, sa.Column('id', sa.Integer, primary_key=True), sa.Column('chat_id', sa.Integer, nullable=False), sa.Column('message', sa.String(256), nullable=False), sa.PrimaryKeyConstraint('id', name='message_id_pkey'),
import aiopg.sa import sqlalchemy as sa __all__ = ['question', 'choice'] meta = sa.MetaData() question = sa.Table( "question", meta, sa.Column("id", sa.Integer, nullable=False), sa.Column("text", sa.String(200), nullable=False), sa.Column("pub_date", sa.Date, nullable=False), # Indexes sa.PrimaryKeyConstraint("id", name="question_id_pkey")) choice = sa.Table( "choice", meta, sa.Column("id", sa.Integer, nullable=False), sa.Column("question_id", sa.Integer, nullable=False), sa.Column("choice_text", sa.String(200), nullable=False), sa.Column("votes", sa.Integer, server_default="0", nullable=False), # Indexes sa.PrimaryKeyConstraint('id', name='choice_id_pkey'), sa.ForeignKeyConstraint(["question_id"], [question.c.id], name="choice_question_id_fkey", ondelete="CASCADE"))
import sqlalchemy as sa __all__ = ['users', 'karma'] meta = sa.MetaData() users = sa.Table( 'users', meta, sa.Column('id', sa.Integer, nullable=False), sa.Column('email', sa.String(256), nullable=False), sa.Column('password_hash', sa.String(512), nullable=False), sa.Column('registration_date', sa.Date, nullable=False), # Indexes # sa.PrimaryKeyConstraint('id', name='users_id_pkey')) karma = sa.Table( 'karma', meta, sa.Column('id', sa.Integer, nullable=False), sa.Column('users_id', sa.Integer, nullable=False), sa.Column('karma', sa.Integer, server_default="0", nullable=False), # Indexes # sa.PrimaryKeyConstraint('id', name='karma_id_pkey'), sa.ForeignKeyConstraint(['users_id'], [users.c.id], name='karma_users_id_fkey', ondelete='CASCADE'), )