Python sqlalchemy 模块,Boolean() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sqlalchemy.Boolean()

项目:podigger    作者:perna    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('topic_suggestion',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('title', sa.String(), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('is_recorded', sa.Boolean(), nullable=False),
    sa.Column('podcast_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['podcast_id'], ['podcast.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_topic_suggestion_id'), 'topic_suggestion', ['id'], unique=False)
    op.create_index(op.f('ix_topic_suggestion_title'), 'topic_suggestion', ['title'], unique=False)
    op.create_index(op.f('ix_episode_id'), 'episode', ['id'], unique=False)
    op.create_index(op.f('ix_podcast_id'), 'podcast', ['id'], unique=False)
    op.create_index(op.f('ix_popular_term_id'), 'popular_term', ['id'], unique=False)
    op.create_index(op.f('ix_tag_id'), 'tag', ['id'], unique=False)
    ### end Alembic commands ###
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.add_column('app', sa.Column('updated', sa.Text, default=make_timestamp))
    op.add_column('app', sa.Column('contacted', sa.Boolean, default=False))
    op.add_column('app', sa.Column('completed', sa.Boolean, default=False))
    # Update all projects to the day the migration is run
    query = "UPDATE app SET updated='%s'" % make_timestamp()
    op.execute(query)
    # Update the state of the projects
    # Put all of them to false
    query = 'UPDATE app SET completed=false'
    op.execute(query)
    # Update to completed those that are not included in the set
    query = "UPDATE app SET completed=true WHERE id NOT IN (SELECT app_id FROM task WHERE state!='completed' OR state IS NULL GROUP BY app_id)"
    op.execute(query)
    # Update to not completed those that do not have any task
    query = "UPDATE app SET completed=false WHERE id NOT IN (SELECT app_id FROM task group by app_id)"
    op.execute(query)
项目:trio2o    作者:openstack    | 项目源码 | 文件源码
def _get_field_value(column):
    """Get field value for resource creating

    returning None indicates that not setting this field in resource dict
    """
    if column.nullable:
        # just skip nullable column
        return None
    if isinstance(column.type, sql.Text):
        return 'fake_text'
    elif isinstance(column.type, sql.Enum):
        return column.type.enums[0]
    elif isinstance(column.type, sql.String):
        return 'fake_str'
    elif isinstance(column.type, sql.Integer):
        return 1
    elif isinstance(column.type, sql.Float):
        return 1.0
    elif isinstance(column.type, sql.Boolean):
        return True
    elif isinstance(column.type, sql.DateTime):
        return datetime.datetime.utcnow()
    else:
        return None
项目:eventor    作者:Acrisel    | 项目源码 | 文件源码
def delay_table(base):
    class Delay(base):
        __tablename__ = 'Delay'

        id_=Column(Integer, Sequence('delay_id_seq'), primary_key=True)
        run_id = Column(String, default='')
        delay_id = Column(String,)
        sequence = Column(Integer,)
        recovery = Column(Integer,)
        seconds = Column(BigInteger, nullable=True)
        active = Column(Boolean, default=False)
        activated = Column(DateTime(), nullable=True,) 
        updated = Column(DateTime(), default=datetime.utcnow) 

        __table_args__ = (
                UniqueConstraint('run_id', 'delay_id', 'sequence', 'recovery'),
                )

        def __repr__(self):
            return "<Delay(id='%s', run_id='%s', delay_id='%s', delay='%s', active='%s', activated='%s')>" % (
                self.id_, self.run_id, self.delay_id, self.seconds, self.active, self.activated)

    return Delay
项目:Leics    作者:LeicsFrameWork    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('default', sa.Boolean(), nullable=True),
    sa.Column('permissions', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_index(op.f('ix_roles_default'), 'roles', ['default'], unique=False)
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=164), nullable=True),
    sa.Column('email', sa.String(length=164), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.Column('password_hash', sa.String(length=164), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
    ### end Alembic commands ###
项目:podigger    作者:perna    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('role',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=255), nullable=True),
    sa.Column('active', sa.Boolean(), nullable=True),
    sa.Column('confirmed_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('roles_users',
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], )
    )
    ### end Alembic commands ###
项目:zun    作者:openstack    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'zun_service',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('report_count', sa.Integer(), nullable=False),
        sa.Column('host', sa.String(length=255), nullable=True),
        sa.Column('binary', sa.String(length=255), nullable=True),
        sa.Column('disabled', sa.Boolean(), nullable=True),
        sa.Column('disabled_reason', sa.String(length=255), nullable=True),
        sa.Column('last_seen_up', sa.DateTime(), nullable=True),
        sa.Column('forced_down', sa.Boolean(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('host', 'binary',
                            name='uniq_zun_service0host0binary')
    )
项目:xiaodi    作者:shenaishiren    | 项目源码 | 文件源码
def _init_cls(cls):
    setattr(cls, '__tablename__', cls.__name__)
    setattr(cls, 'id', Column(Integer, primary_key=True, autoincrement=True))
    for _str in getattr(cls, 'stringV', []):
        setattr(cls, _str, Column(String(DB_STRING_LENGTH)))
    for _int in getattr(cls, 'integerV', []):
        setattr(cls, _int, Column(Integer))
    for _bool in getattr(cls, 'boolV', []):
        setattr(cls, _bool, Column(Boolean))
    for _float in getattr(cls, 'floatV', []):
        setattr(cls, _float, Column(Float))
    for _time in getattr(cls, 'timeV', []):
        setattr(cls, _time, Column(DateTime, default=datetime.utcnow))
    for key, value in getattr(cls, 'foreignKeyV', {}).iteritems():
        setattr(cls, key, Column(Integer, ForeignKey(value), primary_key=True))
    setattr(cls, 'to_json', _convert_attr_to_dict)
项目:picasso    作者:openstack    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'apps',
        sa.Column('id', sa.String(255), nullable=False),
        sa.Column('project_id', sa.String(255), nullable=False),
        sa.Column('description', sa.String(255), nullable=True),
        sa.Column('created_at', sa.String(255)),
        sa.Column('updated_at', sa.String(255)),
        sa.Column('name', sa.String(255), nullable=False, primary_key=True),
    )
    op.create_table(
        'routes',
        sa.Column('project_id', sa.String(255), nullable=False),
        sa.Column('path', sa.String(255), nullable=False, primary_key=True),
        sa.Column('is_public', sa.Boolean(create_constraint=False), nullable=False),
        sa.Column('app_name', sa.String(255), nullable=False, primary_key=True),
        sa.Column('created_at', sa.String(255), nullable=False),
        sa.Column('updated_at', sa.String(255), nullable=False),
    )
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('comments',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('body_html', sa.Text(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('disabled', sa.Boolean(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('post_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('ix_comments_timestamp', 'comments', ['timestamp'], unique=False)
    ### end Alembic commands ###
项目:GWMMS    作者:lvhuiyang    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('username', sa.String(length=64), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.Column('confirmed', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
    op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
    op.drop_table('Products')
    ### end Alembic commands ###
项目:ml-annotate    作者:planbrothers    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user',
    sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
    sa.Column('username', sa.Unicode(length=255), nullable=False),
    sa.Column('password', sqlalchemy_utils.types.password.PasswordType(), nullable=False),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('is_superuser', sa.Boolean(), server_default='FALSE', nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
    op.create_table('user_problem',
    sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
    sa.Column('problem_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
    sa.Column('user_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
    sa.ForeignKeyConstraint(['problem_id'], ['problem.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_problem_user_id'), 'user_problem', ['user_id'], unique=False)
    # ### end Alembic commands ###
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('comments',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('body_html', sa.Text(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('disabled', sa.Boolean(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('post_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_comments_timestamp'), 'comments', ['timestamp'], unique=False)
    op.alter_column(u'statistic_visitor', 'referred',
               existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
               nullable=True,
               existing_server_default=sa.text(u"''"))
    ### end Alembic commands ###
项目:ShelbySearch    作者:Agentscreech    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cars',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('vin', sa.String(), nullable=True),
    sa.Column('year', sa.Integer(), nullable=True),
    sa.Column('r_model', sa.Boolean(), nullable=True),
    sa.Column('color', sa.String(), nullable=True),
    sa.Column('stripe', sa.String(), nullable=True),
    sa.Column('electronics', sa.Boolean(), nullable=True),
    sa.Column('convenience', sa.Boolean(), nullable=True),
    sa.Column('painted_roof', sa.Boolean(), nullable=True),
    sa.Column('build_date', sa.String(), nullable=True),
    sa.Column('price', sa.String(), nullable=True),
    sa.Column('dealer', sa.String(), nullable=True),
    sa.Column('address', sa.String(), nullable=True),
    sa.Column('phone', sa.String(), nullable=True),
    sa.Column('url', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###
项目:aiorchestra-persistence    作者:aiorchestra    | 项目源码 | 文件源码
def upgrade():

    op.create_table(
        'context',
        sa.Column('name', sa.String(), nullable=False, unique=True, primary_key=True),
        sa.Column('status', sa.String(), nullable=False),
        sa.Column('template_path', sa.String(), nullable=False),
        sa.Column('inputs', sa.Text(), nullable=False),
    )
    op.create_table(
        'node',
        sa.Column('context', sa.String(), sa.ForeignKey('context.name'), ),
        sa.Column('name', sa.String(), nullable=False, unique=True),
        sa.Column('is_provisioned', sa.Boolean(), nullable=False),
        sa.Column('properties', sa.Text(), nullable=True),
        sa.Column('attributes', sa.Text(), nullable=True),
        sa.Column('runtime_properties', sa.Text(), nullable=True),
    )
项目:dazzar    作者:Philaeux    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('scoreboard',
    sa.Column('user_id', sa.BigInteger(), nullable=False),
    sa.Column('ladder_name', sa.String(), nullable=False),
    sa.Column('mmr', sa.Integer(), nullable=False),
    sa.Column('matches', sa.Integer(), server_default='0', nullable=False),
    sa.Column('win', sa.Integer(), server_default='0', nullable=False),
    sa.Column('loss', sa.Integer(), server_default='0', nullable=False),
    sa.Column('dodge', sa.Integer(), server_default='0', nullable=False),
    sa.Column('leave', sa.Integer(), server_default='0', nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('user_id', 'ladder_name')
    )
    op.create_index(op.f('ix_scoreboard_mmr'), 'scoreboard', ['mmr'], unique=False)
    op.add_column('match', sa.Column('radiant_win', sa.Boolean(), nullable=True))
    op.add_column('match', sa.Column('section', sa.String(), server_default='high', nullable=False))
    op.add_column('player_in_match', sa.Column('is_dodge', sa.Boolean(), server_default='false', nullable=False))
    op.add_column('user', sa.Column('section', sa.String(), nullable=True))
    ### end Alembic commands ###
项目:heutagogy-backend    作者:heutagogy    | 项目源码 | 文件源码
def upgrade():
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=255), nullable=False),
    sa.Column('password', sa.String(), nullable=False),
    sa.Column('email', sa.String(length=255), nullable=True),
    sa.Column('confirmed_at', sa.DateTime(), nullable=True),
    sa.Column('is_active', sa.Boolean(), server_default='0', nullable=False),
    sa.Column('first_name', sa.String(length=255), server_default='', nullable=False),
    sa.Column('last_name', sa.String(length=255), server_default='', nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('username')
    )
    op.create_table('bookmark',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user', sa.Integer(), nullable=False),
    sa.Column('timestamp', sa.DateTime(), nullable=False),
    sa.Column('url', sa.String(), nullable=False),
    sa.Column('title', sa.String(), nullable=False),
    sa.Column('read', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['user'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
项目:sqlacodegen    作者:agronholm    | 项目源码 | 文件源码
def test_fancy_coltypes(self):
        Table(
            'simple_items', self.metadata,
            Column('enum', ENUM('A', 'B', name='blah')),
            Column('bool', BOOLEAN),
            Column('number', NUMERIC(10, asdecimal=False)),
        )

        assert self.generate_code() == """\
# coding: utf-8
from sqlalchemy import Boolean, Column, Enum, MetaData, Numeric, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('enum', Enum('A', 'B', name='blah')),
    Column('bool', Boolean),
    Column('number', Numeric(10, asdecimal=False))
)
"""
项目:sqlacodegen    作者:agronholm    | 项目源码 | 文件源码
def test_boolean_detection(self):
        Table(
            'simple_items', self.metadata,
            Column('bool1', INTEGER),
            Column('bool2', SMALLINT),
            Column('bool3', TINYINT),
            CheckConstraint('simple_items.bool1 IN (0, 1)'),
            CheckConstraint('simple_items.bool2 IN (0, 1)'),
            CheckConstraint('simple_items.bool3 IN (0, 1)')
        )

        assert self.generate_code() == """\
# coding: utf-8
from sqlalchemy import Boolean, Column, MetaData, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('bool1', Boolean),
    Column('bool2', Boolean),
    Column('bool3', Boolean)
)
"""
项目:sqlacodegen    作者:agronholm    | 项目源码 | 文件源码
def test_schema_boolean(self):
        Table(
            'simple_items', self.metadata,
            Column('bool1', INTEGER),
            CheckConstraint('testschema.simple_items.bool1 IN (0, 1)'),
            schema='testschema'
        )

        assert self.generate_code() == """\
# coding: utf-8
from sqlalchemy import Boolean, Column, MetaData, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('bool1', Boolean),
    schema='testschema'
)
"""
项目:GenomicsSampleAPIs    作者:Intel-HLS    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'reference',
        sa.Column('id', sa.BigInteger, primary_key=True),
        sa.Column('guid', sa.String(36), nullable=False, unique=True),
        sa.Column('length', sa.BigInteger),
        sa.Column('reference_set_id', sa.BigInteger,
                  sa.ForeignKey('reference_set.id'), nullable=False),
        sa.Column('md5_checksum', sa.String(32)),
        sa.Column('name', sa.Text),
        sa.Column('source_uri', sa.Text),
        sa.Column('is_derived', sa.Boolean),
        sa.Column('source_divergence', sa.Float),
        sa.Column('ncbi_taxon_id', sa.Integer),
        sa.Column('offset', sa.BigInteger)
    )
项目:quark    作者:openstack    | 项目源码 | 文件源码
def setUp(self):
        super(Test4fc07b41d45c, self).setUp()
        self.previous_revision = "42a3c8c0db75"
        self.current_revision = "4fc07b41d45c"
        self.metadata = sa.MetaData(bind=self.engine)
        # NOTE(thomasem): Create a quark_ip_addresses table that has an
        # identical schema as the revision before it for the columns this data
        # migration is concerned with.
        self.ip_addresses_table = sa.Table(
            'quark_ip_addresses', self.metadata,
            sa.Column('id', sa.String(length=36), primary_key=True),
            sa.Column('_deallocated', sa.Boolean()),
            sa.Column('address_type', sa.Enum('fixed', 'shared', 'floating'))
        )
        self.metadata.create_all()
        alembic_command.stamp(self.config, self.previous_revision)
项目:aiohttp_admin    作者:aio-libs    | 项目源码 | 文件源码
def sa_table():
    choices = ['a', 'b', 'c']
    meta = sa.MetaData()
    post = sa.Table(
        'test_post', meta,
        sa.Column('id', sa.Integer, nullable=False),
        sa.Column('title', sa.String(200), nullable=False),
        sa.Column('category', sa.String(200), nullable=True),
        sa.Column('body', sa.Text, nullable=False),
        sa.Column('views', sa.Integer, nullable=False),
        sa.Column('average_note', sa.Float, nullable=False),
        # sa.Column('pictures', postgresql.JSON, server_default='{}'),
        sa.Column('published_at', sa.DateTime, nullable=False),
        # sa.Column('tags', postgresql.ARRAY(sa.Integer), server_default='{}'),
        sa.Column('status',
                  sa.Enum(*choices, name="enum_name", native_enum=False),
                  server_default="a", nullable=False),
        sa.Column('visible', sa.Boolean, nullable=False),

        # Indexes #
        sa.PrimaryKeyConstraint('id', name='post_id_pkey'))
    return post
项目:floranet    作者:Fluent-networks    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'gateways',
        sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
        sa.Column('host', INET, nullable=False, unique=True),
        sa.Column('name', sa.String, nullable=True),
        sa.Column('enabled', sa.Boolean, nullable=False, default=True),
        sa.Column('eui', sa.Numeric, nullable=False, unique=True),
        sa.Column('power', sa.Integer, nullable=False),
        sa.Column('port', sa.String, nullable=True),
        sa.Column('latitude', sa.Float, nullable=True),
        sa.Column('longitude', sa.Float, nullable=True),
        sa.Column('created', sa.DateTime(timezone=True), nullable=False),
        sa.Column('updated', sa.DateTime(timezone=True), nullable=False),
        )
    op.add_column('devices',
        sa.Column('devnonce', sa.dialects.postgresql.ARRAY(sa.Integer())))
项目:floranet    作者:Fluent-networks    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'config',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.String, nullable=False),
        sa.Column('listen', INET, nullable=False),
        sa.Column('port', sa.Integer, nullable=False),
        sa.Column('webport', sa.Integer, nullable=False),
        sa.Column('apitoken', sa.String, nullable=False),
        sa.Column('freqband', sa.String, nullable=False),
        sa.Column('netid', sa.Integer, nullable=False),
        sa.Column('duplicateperiod', sa.Integer, nullable=False),
        sa.Column('fcrelaxed', sa.Boolean, nullable=False),
        sa.Column('otaastart', sa.Integer, nullable=False),
        sa.Column('otaaend', sa.Integer, nullable=False),
        sa.Column('macqueueing', sa.Boolean, nullable=False),
        sa.Column('macqueuelimit', sa.Integer, nullable=False),
        sa.Column('adrenable', sa.Boolean, nullable=False),
        sa.Column('adrmargin', sa.Float, nullable=False),
        sa.Column('adrcycletime', sa.Integer, nullable=False),
        sa.Column('adrmessagetime', sa.Integer, nullable=False),
        sa.Column('created', sa.DateTime(timezone=True), nullable=False),
        sa.Column('updated', sa.DateTime(timezone=True), nullable=False),
        )
项目:fabric8-analytics-server    作者:fabric8-analytics    | 项目源码 | 文件源码
def upgrade():
    """Upgrade the database to a newer revision."""
    # commands auto generated by Alembic - please adjust! ###
    op.create_table('batch',
                    sa.Column('token', sa.Integer(), nullable=False),
                    sa.Column('started_at', sa.DateTime(), nullable=True),
                    sa.Column('epvs', postgresql.JSONB(), nullable=True),
                    sa.PrimaryKeyConstraint('token'))
    op.create_table('review',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('approved', sa.Boolean(), nullable=True),
                    sa.Column('user', sa.Integer(), nullable=True),
                    sa.Column('timestamp', sa.DateTime(), nullable=True),
                    sa.Column('comment', sa.Text(), nullable=True),
                    sa.Column('epv', sa.String(length=255), nullable=True),
                    sa.ForeignKeyConstraint(['user'], ['user.id'], ),
                    sa.PrimaryKeyConstraint('id'))
    # end Alembic commands ###
项目:fabric8-analytics-server    作者:fabric8-analytics    | 项目源码 | 文件源码
def upgrade():
    """Upgrade the database to a newer revision."""
    # commands auto generated by Alembic - please adjust! ###
    op.create_table('role',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=80), nullable=True),
                    sa.Column('description', sa.String(length=255), nullable=True),
                    sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('name'))
    op.create_table('user',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('login', sa.String(length=255), nullable=True),
                    sa.Column('email', sa.String(length=255), nullable=True),
                    sa.Column('password', sa.String(length=255), nullable=True),
                    sa.Column('active', sa.Boolean(), nullable=True),
                    sa.Column('token', sa.String(length=255), nullable=True),
                    sa.Column('token_expires', sa.DateTime(), nullable=True),
                    sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('login'))
    op.create_table('roles_users',
                    sa.Column('user_id', sa.Integer(), nullable=True),
                    sa.Column('role_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
                    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ))
    # end Alembic commands ###
项目:zeus    作者:getsentry    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('email',
                    sa.Column('user_id', zeus.db.types.guid.GUID(),
                              nullable=False),
                    sa.Column('email', sa.String(length=128), nullable=False),
                    sa.Column('verified', sa.Boolean(), nullable=True),
                    sa.Column('id', zeus.db.types.guid.GUID(), nullable=False),
                    sa.Column('date_created', sa.TIMESTAMP(timezone=True),
                              server_default=sa.text('now()'), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['user_id'], ['user.id'], ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('user_id', 'email',
                                        name='unq_user_email')
                    )
    op.create_index(op.f('ix_email_user_id'), 'email',
                    ['user_id'], unique=False)
    # ### end Alembic commands ###
项目:vcf2db    作者:quinlan-lab    | 项目源码 | 文件源码
def variants_gene_columns(self):
        # all of these are also stored in the variant_impacts table.
        return [
            sql.Column("gene", sql.String(20)),
            sql.Column("transcript", sql.String(20)),
            sql.Column("is_exonic", sql.Boolean()),
            sql.Column("is_coding", sql.Boolean()),
            sql.Column("is_lof", sql.Boolean()),
            sql.Column("is_splicing", sql.Boolean()),
            sql.Column("exon", sql.String(8)),
            sql.Column("codon_change", sql.TEXT()),
            sql.Column("aa_change", sql.TEXT()),
            sql.Column("aa_length", sql.String(8)),
            sql.Column("biotype", sql.String(50)),
            sql.Column("impact", sql.String(20)),
            sql.Column("impact_so", sql.String(20)),
            sql.Column("impact_severity", sql.String(4)),
            sql.Column("polyphen_pred", sql.String(20)),
            sql.Column("polyphen_score", sql.Float()),
            sql.Column("sift_pred", sql.String(20)),
            sql.Column("sift_score", sql.Float()),
            ]
项目:rucio    作者:rucio01    | 项目源码 | 文件源码
def upgrade():
    '''
    upgrade method
    '''
    if context.get_context().dialect.name not in ['sqlite']:
        create_table('sources_history',
                     sa.Column('request_id', GUID()),
                     sa.Column('scope', sa.String(25)),
                     sa.Column('name', sa.String(255)),
                     sa.Column('rse_id', GUID()),
                     sa.Column('dest_rse_id', GUID()),
                     sa.Column('url', sa.String(2048)),
                     sa.Column('bytes', sa.BigInteger),
                     sa.Column('ranking', sa.Integer()),
                     sa.Column('is_using', sa.Boolean(), default=False))
        add_column('requests', sa.Column('estimated_at', sa.DateTime))
        add_column('requests_history', sa.Column('estimated_at', sa.DateTime))
项目:metaseek    作者:ahoarfrost    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('dataset', 'collection_date',
               existing_type=mysql.DATETIME(),
               type_=sa.Text(),
               existing_nullable=True)
    op.alter_column('dataset', 'latitude',
               existing_type=mysql.FLOAT(),
               type_=sa.Text(),
               existing_nullable=True)
    op.alter_column('dataset', 'longitude',
               existing_type=mysql.FLOAT(),
               type_=sa.Text(),
               existing_nullable=True)
    op.alter_column('user', 'admin',
               existing_type=mysql.TINYINT(display_width=1),
               type_=sa.Boolean(),
               existing_nullable=True)
    # ### end Alembic commands ###
项目:metaseek    作者:ahoarfrost    | 项目源码 | 文件源码
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('user', 'admin',
               existing_type=sa.Boolean(),
               type_=mysql.TINYINT(display_width=1),
               existing_nullable=True)
    op.alter_column('dataset', 'longitude',
               existing_type=sa.Text(),
               type_=mysql.FLOAT(),
               existing_nullable=True)
    op.alter_column('dataset', 'latitude',
               existing_type=sa.Text(),
               type_=mysql.FLOAT(),
               existing_nullable=True)
    op.alter_column('dataset', 'collection_date',
               existing_type=sa.Text(),
               type_=mysql.DATETIME(),
               existing_nullable=True)
    # ### end Alembic commands ###
项目:project    作者:Junctionzc    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('comments',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('body_html', sa.Text(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('disabled', sa.Boolean(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('post_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_comments_timestamp'), 'comments', ['timestamp'], unique=False)
    ### end Alembic commands ###
项目:CivilServant    作者:mitmedialab    | 项目源码 | 文件源码
def upgrade_development():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('event_hooks',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('experiment_id', sa.Integer(), nullable=True),
    sa.Column('is_active', sa.Boolean(), nullable=True),
    sa.Column('call_when', sa.Integer(), nullable=True),
    sa.Column('caller_controller', sa.String(length=256), nullable=False),
    sa.Column('caller_method', sa.String(length=256), nullable=False),
    sa.Column('callee_module', sa.String(length=256), nullable=False),
    sa.Column('callee_controller', sa.String(length=256), nullable=False),
    sa.Column('callee_method', sa.String(length=256), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_event_hooks_experiment_id'), 'event_hooks', ['experiment_id'], unique=False)
    op.create_index(op.f('ix_event_hooks_name'), 'event_hooks', ['name'], unique=False)
    # ### end Alembic commands ###
项目:CivilServant    作者:mitmedialab    | 项目源码 | 文件源码
def upgrade_test():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('event_hooks',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('experiment_id', sa.Integer(), nullable=True),
    sa.Column('is_active', sa.Boolean(), nullable=True),
    sa.Column('call_when', sa.Integer(), nullable=True),
    sa.Column('caller_controller', sa.String(length=256), nullable=False),
    sa.Column('caller_method', sa.String(length=256), nullable=False),
    sa.Column('callee_module', sa.String(length=256), nullable=False),
    sa.Column('callee_controller', sa.String(length=256), nullable=False),
    sa.Column('callee_method', sa.String(length=256), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_event_hooks_experiment_id'), 'event_hooks', ['experiment_id'], unique=False)
    op.create_index(op.f('ix_event_hooks_name'), 'event_hooks', ['name'], unique=False)
    # ### end Alembic commands ###
项目:CivilServant    作者:mitmedialab    | 项目源码 | 文件源码
def upgrade_production():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('event_hooks',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('experiment_id', sa.Integer(), nullable=True),
    sa.Column('is_active', sa.Boolean(), nullable=True),
    sa.Column('call_when', sa.Integer(), nullable=True),
    sa.Column('caller_controller', sa.String(length=256), nullable=False),
    sa.Column('caller_method', sa.String(length=256), nullable=False),
    sa.Column('callee_module', sa.String(length=256), nullable=False),
    sa.Column('callee_controller', sa.String(length=256), nullable=False),
    sa.Column('callee_method', sa.String(length=256), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_event_hooks_experiment_id'), 'event_hooks', ['experiment_id'], unique=False)
    op.create_index(op.f('ix_event_hooks_name'), 'event_hooks', ['name'], unique=False)
    # ### end Alembic commands ###
项目:m2m    作者:neo1218    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('default', sa.Boolean(), nullable=True),
    sa.Column('permissions', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_index(op.f('ix_roles_default'), 'roles', ['default'], unique=False)
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=164), nullable=True),
    sa.Column('email', sa.String(length=164), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.Column('password_hash', sa.String(length=164), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
    ### end Alembic commands ###
项目:dbas    作者:hhucn    | 项目源码 | 文件源码
def sql_timestamp_pretty_print(ts, lang='en', humanize=True, with_exact_time=False):
    """
    Pretty printing for sql timestamp in dependence of the language.

    :param ts: timestamp (arrow) as string
    :param lang: language
    :param humanize: Boolean
    :param with_exact_time: Boolean
    :return: String
    """
    if humanize:
        # if lang == 'de':
        ts = ts.to('Europe/Berlin')
        # else:
        #    ts = ts.to('US/Pacific')
        return ts.humanize(locale=lang)
    else:
        if lang == 'de':
            return ts.format('DD.MM.YYYY' + (', HH:mm:ss ' if with_exact_time else ''))
        else:
            return ts.format('YYYY-MM-DD' + (', HH:mm:ss ' if with_exact_time else ''))
项目:dbas    作者:hhucn    | 项目源码 | 文件源码
def __init__(self, premisesgroup, statement, is_negated, author, issue, is_disabled=False):
        """
        Initializes a row in current premises-table

        :param premisesgroup: PremiseGroup.uid
        :param statement: Statement.uid
        :param is_negated: Boolean
        :param author: User.uid
        :param issue: Issue.uid
        :param is_disabled: Boolean
        :return: None
        """
        self.premisesgroup_uid = premisesgroup
        self.statement_uid = statement
        self.is_negated = is_negated
        self.author_uid = author
        self.timestamp = get_now()
        self.issue_uid = issue
        self.is_disabled = is_disabled
项目:dbas    作者:hhucn    | 项目源码 | 文件源码
def __init__(self, premisegroup, issupportive, author, issue, conclusion=None, argument=None, is_disabled=False):
        """
        Initializes a row in current argument-table

        :param premisegroup: PremiseGroup.uid
        :param issupportive: Boolean
        :param author: User.uid
        :param issue: Issue.uid
        :param conclusion: Default 0, which will be None
        :param argument: Default 0, which will be None
        :param is_disabled: Boolean
        :return: None
        """
        self.premisesgroup_uid = premisegroup
        self.conclusion_uid = None if conclusion == 0 else conclusion
        self.argument_uid = None if argument == 0 else argument
        self.is_supportive = issupportive
        self.author_uid = author
        self.argument_uid = argument
        self.issue_uid = issue
        self.is_disabled = is_disabled
        self.timestamp = get_now()
项目:dbas    作者:hhucn    | 项目源码 | 文件源码
def __init__(self, from_author_uid, to_author_uid, topic, content, is_inbox=True, read=False):
        """
        Inits a row in current message table

        :param from_author_uid: user.uid
        :param to_author_uid: user.uid
        :param topic: String
        :param content: String
        :param is_inbox: Boolean
        :param read: Boolean
        """
        self.from_author_uid = from_author_uid
        self.to_author_uid = to_author_uid
        self.topic = topic
        self.content = content
        self.timestamp = get_now()
        self.read = read
        self.is_inbox = is_inbox
项目:dbas    作者:hhucn    | 项目源码 | 文件源码
def __init__(self, detector, argument=None, statement=None, reason='', is_executed=False, is_revoked=False):
        """
        Inits a row in current review delete table

        :param detector: User.uid
        :param argument: Argument.uid
        :param reason: ReviewDeleteReason.uid
        :param is_executed: Boolean
        """
        self.detector_uid = detector
        self.argument_uid = argument
        self.statement_uid = statement
        self.reason_uid = reason
        self.timestamp = get_now()
        self.is_executed = is_executed
        self.is_revoked = is_revoked
项目:dbas    作者:hhucn    | 项目源码 | 文件源码
def __init__(self, detector, argument=None, statement=None, is_executed=False, is_revoked=False):
        """
        Inits a row in current review edit table

        :param detector: User.uid
        :param argument: Argument.uid
        :param statement: Statement.uid
        :param is_executed: Boolean
        :param is_revoked: Boolean
        """
        self.detector_uid = detector
        self.argument_uid = argument
        self.statement_uid = statement
        self.timestamp = get_now()
        self.is_executed = is_executed
        self.is_revoked = is_revoked
项目:dbas    作者:hhucn    | 项目源码 | 文件源码
def __init__(self, detector, argument=None, statement=None, is_executed=False, is_revoked=False):
        """
        Inits a row in current review optimization table

        :param detector: User.uid
        :param argument: Argument.uid
        :param statement: Statement.uid
        :param is_executed: Boolean
        :param is_revoked: Boolean
        """
        self.detector_uid = detector
        self.argument_uid = argument
        self.statement_uid = statement
        self.timestamp = get_now()
        self.is_executed = is_executed
        self.is_revoked = is_revoked
项目:dbas    作者:hhucn    | 项目源码 | 文件源码
def __init__(self, detector, duplicate_statement=None, original_statement=None, is_executed=False,
                 is_revoked=False):
        """
        Inits a row in current review duplicate table

        :param detector: User.uid
        :param duplicate_statement: Statement.uid
        :param original_statement: Statement.uid
        :param is_executed: Boolean
        :param is_revoked: Boolean
        """
        self.detector_uid = detector
        self.duplicate_statement_uid = duplicate_statement
        self.original_statement_uid = original_statement
        self.timestamp = get_now()
        self.is_executed = is_executed
        self.is_revoked = is_revoked
项目:dbas    作者:hhucn    | 项目源码 | 文件源码
def __init__(self, author, reviews, was_ongoing=False):
        """
        Inits a row in current review locks table

        :param author: User.uid
        :param reviews: dict with possible review uids
        :param was_ongoing: Boolean
        """
        self.author_uid = author
        self.review_edit_uid = reviews['edit'] if 'edit' in reviews else None
        self.review_delete_uid = reviews['delete'] if 'delete' in reviews else None
        self.review_optimization_uid = reviews['optimization'] if 'optimization' in reviews else None
        self.review_duplicate_uid = reviews['duplicate'] if 'duplicate' in reviews else None
        self.review_merge_uid = reviews['merge'] if 'merge' in reviews else None
        self.review_split_uid = reviews['split'] if 'split' in reviews else None
        self.was_ongoing = was_ongoing
        self.timestamp = get_now()
项目:fuel-nailgun-extension-iac    作者:openstack    | 项目源码 | 文件源码
def upgrade():
    table_prefix = context.config.get_main_option('table_prefix')
    op.add_column(
        table_prefix + 'repos',
        sa.Column('manage_master', sa.Boolean(), nullable=True)
    )
项目:BookCloud    作者:livro-aberto    | 项目源码 | 文件源码
def column_reflect(inspector, table, column_info):
    if type(column_info['type']) is mysql.TINYINT:
        column_info['type'] = Boolean()

#from application import User, Project, Branch, Thread, Comment, Likes, User_Tag, File_Tag, Named_Tag, Custom_Tag, Free_Tag, limiter, mail

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.add_column('user', sa.Column('privacy_mode', sa.Boolean, default=True))
    query = 'UPDATE "user" SET privacy_mode=true;'
    op.execute(query)
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.add_column('blogpost', sa.Column('published', sa.Boolean, default=False))
    op.add_column('blogpost', sa.Column('updated', sa.Text,
                                       default=make_timestamp))
    sql = 'update blogpost set published=true'
    op.execute(sql)