当前位置: 首页>>代码示例>>Python>>正文


Python sqlalchemy.Enum方法代码示例

本文整理汇总了Python中sqlalchemy.Enum方法的典型用法代码示例。如果您正苦于以下问题:Python sqlalchemy.Enum方法的具体用法?Python sqlalchemy.Enum怎么用?Python sqlalchemy.Enum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy的用法示例。


在下文中一共展示了sqlalchemy.Enum方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def upgrade():
    op.create_table(
        'project_locks',
        sa.Column('project_id',
                  sa.Integer,
                  sa.ForeignKey(
                    'projects.id', onupdate='CASCADE', ondelete='CASCADE'
                  ),
                  nullable=False,
                  primary_key=True
        ),
        sa.Column('lock_type',
                  sa.Enum(
                    'WORKER',
                    name='lock_type_enum'
                  ),
                  nullable=False,
                  primary_key=True
        )
    )

    # Add WORKER locks everywhere
    conn = op.get_bind()
    conn.execute("""INSERT INTO project_locks (project_id, lock_type)
                    SELECT id, 'WORKER' from projects""") 
开发者ID:Pagure,项目名称:pagure,代码行数:27,代码来源:5179e99d35a5_add_lock_types.py

示例2: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def upgrade():
    periodic_table = op.create_table(
        'opendaylight_periodic_task',
        sa.Column('state', sa.Enum(odl_const.PENDING, odl_const.PROCESSING,
                                   name='state'),
                  nullable=False),
        sa.Column('processing_operation', sa.String(70)),
        sa.Column('task', sa.String(70), primary_key=True),
        sa.Column('lock_updated', sa.TIMESTAMP, nullable=False,
                  server_default=sa.func.now(),
                  onupdate=sa.func.now())
    )
    op.bulk_insert(periodic_table,
                   [{'task': 'maintenance',
                     'state': odl_const.PENDING},
                    {'task': 'hostconfig',
                     'state': odl_const.PENDING}]) 
开发者ID:openstack,项目名称:networking-odl,代码行数:19,代码来源:6f7dfb241354_create_opendaylight_preiodic_task_table.py

示例3: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('apple_subscription',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('expires_date', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.Column('original_transaction_id', sa.String(length=256), nullable=False),
    sa.Column('receipt_data', sa.Text(), nullable=False),
    sa.Column('plan', sa.Enum('monthly', 'yearly', name='planenum_apple'), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id')
    )
    op.alter_column('file', 'user_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    # ### end Alembic commands ### 
开发者ID:simple-login,项目名称:app,代码行数:21,代码来源:2020_041911_dd911f880b75_.py

示例4: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def upgrade():
    op.create_table(
        'error_logs',
        IDColumn(),
        sa.Column('created_at', sa.DateTime(timezone=True),
                  server_default=sa.func.now(), index=True),
        sa.Column('severity', sa.Enum('critical', 'error', 'warning', 'info', 'debug', name='errorlog_severity'),
                  index=True),
        sa.Column('source', sa.String),
        sa.Column('user', GUID, sa.ForeignKey('users.uuid'), nullable=True, index=True),
        sa.Column('is_read', sa.Boolean, default=False, index=True),
        sa.Column('is_cleared', sa.Boolean, default=False, index=True),
        sa.Column('message', sa.Text),
        sa.Column('context_lang', sa.String),
        sa.Column('context_env', postgresql.JSONB()),
        sa.Column('request_url', sa.String, nullable=True),
        sa.Column('request_status', sa.Integer, nullable=True),
        sa.Column('traceback', sa.Text, nullable=True),
    ) 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:21,代码来源:d2aafa234374_create_error_logs_table.py

示例5: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def upgrade():
    op.create_table(
        'session_templates',
        IDColumn('id'),
        sa.Column('created_at', sa.DateTime(timezone=True),
                  server_default=sa.func.now(), index=True),
        sa.Column('is_active', sa.Boolean, default=True),
        sa.Column('type',
                  sa.Enum('TASK', 'CLUSTER', name='templatetypes'),
                  nullable=False,
                  server_default='TASK'
                  ),
        sa.Column('domain_name', sa.String(length=64), sa.ForeignKey('domains.name'), nullable=False),
        sa.Column('group_id', GUID, sa.ForeignKey('groups.id'), nullable=True),
        sa.Column('user_uuid', GUID, sa.ForeignKey('users.uuid'), nullable=False),

        sa.Column('name', sa.String(length=128), nullable=True),
        sa.Column('template', sa.String(length=16 * 1024), nullable=False)
    )
    op.add_column(
        'kernels',
        sa.Column('bootstrap_script', sa.String(length=4 * 1024), nullable=True)
    ) 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:25,代码来源:ce209920f654_create_task_template_table.py

示例6: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def upgrade():
    userstatus.create(op.get_bind())
    op.add_column(
        'users',
        sa.Column('status', sa.Enum(*userstatus_choices, name='userstatus'), nullable=True)
    )
    op.add_column('users', sa.Column('status_info', sa.Unicode(), nullable=True))

    # Set user's status field.
    conn = op.get_bind()
    query = textwrap.dedent(
        "UPDATE users SET status = 'active', status_info = 'migrated' WHERE is_active = 't';"
    )
    conn.execute(query)
    query = textwrap.dedent(
        "UPDATE users SET status = 'inactive', status_info = 'migrated' WHERE is_active <> 't';"
    )
    conn.execute(query)

    op.alter_column('users', column_name='status', nullable=False)
    op.drop_column('users', 'is_active') 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:23,代码来源:0d553d59f369_users_replace_is_active_to_status_and_its_info.py

示例7: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def upgrade():
    agentstatus.create(op.get_bind())
    kernelstatus.create(op.get_bind())
    op.add_column('agents', sa.Column('lost_at', sa.DateTime(timezone=True), nullable=True))
    op.add_column('agents', sa.Column('status', sa.Enum('ALIVE', 'LOST', 'RESTARTING', 'TERMINATED', name='agentstatus'), nullable=False))
    op.create_index(op.f('ix_agents_status'), 'agents', ['status'], unique=False)
    op.add_column('kernels', sa.Column('agent_addr', sa.String(length=128), nullable=False))
    op.add_column('kernels', sa.Column('cpu_slot', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('gpu_slot', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('mem_slot', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('repl_in_port', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('repl_out_port', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('stdin_port', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('stdout_port', sa.Integer(), nullable=False))
    op.drop_column('kernels', 'allocated_cores')
    op.add_column('kernels', sa.Column('cpu_set', sa.ARRAY(sa.Integer), nullable=True))
    op.add_column('kernels', sa.Column('gpu_set', sa.ARRAY(sa.Integer), nullable=True))
    op.alter_column('kernels', column_name='status', type_=sa.Enum(*kernelstatus_choices, name='kernelstatus'),
                    postgresql_using='status::kernelstatus') 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:21,代码来源:0f3bc98edaa0_more_status.py

示例8: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def upgrade():
    blockchain_status = postgresql.ENUM('PENDING', 'SUCCESS', 'FAILED', name='blockchainstatus')
    blockchain_status.create(op.get_bind())

    op.create_table('worker_messages',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('authorising_user_id', sa.Integer(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('message', sa.String(), nullable=True),
    sa.Column('error', sa.String(), nullable=True),
    sa.Column('worker_timestamp', sa.DateTime(), nullable=True),
    sa.Column('blockchain_task_uuid', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.add_column('credit_transfer', sa.Column('blockchain_hash', sa.String(), nullable=True))
    op.add_column('credit_transfer', sa.Column('blockchain_status', sa.Enum('PENDING', 'SUCCESS', 'FAILED', name='blockchainstatus'), nullable=True))
    op.add_column('credit_transfer', sa.Column('last_worker_update', sa.DateTime(), nullable=True))
    op.add_column('exchange', sa.Column('blockchain_hash', sa.String(), nullable=True))
    op.add_column('exchange', sa.Column('blockchain_status', sa.Enum('PENDING', 'SUCCESS', 'FAILED', name='blockchainstatus'), nullable=True))
    op.add_column('exchange', sa.Column('last_worker_update', sa.DateTime(), nullable=True))
    op.create_index(op.f('ix_worker_messages_table_blockchain_task_uuid'), 'worker_messages', ['blockchain_task_uuid'], unique=False) 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:24,代码来源:d7b89a614ae9_.py

示例9: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('fiat_ramp',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('authorising_user_id', sa.Integer(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('_payment_method', sa.String(), nullable=True),
    sa.Column('payment_amount', sa.Integer(), nullable=True),
    sa.Column('payment_reference', sa.String(), nullable=True),
    sa.Column('payment_status', sa.Enum('PENDING', 'FAILED', 'COMPLETE', name='fiatrampstatusenum'), nullable=True),
    sa.Column('credit_transfer_id', sa.Integer(), nullable=True),
    sa.Column('token_id', sa.Integer(), nullable=True),
    sa.Column('payment_metadata', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.ForeignKeyConstraint(['credit_transfer_id'], ['credit_transfer.id'], ),
    sa.ForeignKeyConstraint(['token_id'], ['token.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ### 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:21,代码来源:cd5cb44c8f7c_.py

示例10: downgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def downgrade():
    op.drop_table("download")
    op.drop_table("build_architecture")
    op.drop_table("displayname")
    op.drop_table("description")
    op.drop_table("icon")
    sa.Enum(name="icon_size").drop(op.get_bind(), checkfirst=False)
    op.drop_table("build")
    op.drop_table("version_service_dependency")
    op.drop_table("package_user_maintainer")
    with op.batch_alter_table("version", schema=None) as batch_op:
        batch_op.drop_index(batch_op.f("ix_version_version"))
    op.drop_table("version")
    op.drop_table("screenshot")
    op.drop_table("user_role")
    op.drop_table("package")
    op.drop_table("service")
    op.drop_table("firmware")
    op.drop_table("language")
    op.drop_table("architecture")
    op.drop_table("role")
    op.drop_table("user") 
开发者ID:SynoCommunity,项目名称:spkrepo,代码行数:24,代码来源:26b4c36c11e_create_database.py

示例11: sa_table

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
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 
开发者ID:aio-libs,项目名称:aiohttp_admin,代码行数:24,代码来源:db_fixtures.py

示例12: document_schema

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def document_schema():
    choices = ['a', 'b', 'c']
    schema = t.Dict({
        t.Key('_id'): MongoId,
        t.Key('title'): t.String(max_length=200),
        t.Key('category'): t.String(max_length=200),
        t.Key('body'): t.String,
        t.Key('views'): t.ToInt,
        t.Key('average_note'): t.ToFloat,
        # t.Key('pictures'): t.Dict({}).allow_extra('*'),
        t.Key('published_at'): DateTime,
        # t.Key('tags'): t.List(t.Int),
        t.Key('status'): t.Enum(*choices),
        t.Key('visible'): t.ToBool,
    })
    return schema 
开发者ID:aio-libs,项目名称:aiohttp_admin,代码行数:18,代码来源:db_fixtures.py

示例13: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def upgrade(migrate_engine):
    meta.bind = migrate_engine

    status_enum = Enum(name='service_statuses_enum', metadata=meta,
                       *SERVICE_STATES)
    status_enum.create(checkfirst=True)

    service_status_table = Table('service_statuses', meta,
        Column('id', UUID(), default=utils.generate_uuid, primary_key=True),
        Column('created_at', DateTime),
        Column('updated_at', DateTime),

        Column('service_name', String(40), nullable=False),
        Column('hostname', String(255), nullable=False),
        Column('heartbeated_at', DateTime, nullable=True),
        Column('status', status_enum, nullable=False),
        Column('stats', Text, nullable=False),
        Column('capabilities', Text, nullable=False),
    )
    service_status_table.create(checkfirst=True) 
开发者ID:openstack,项目名称:designate,代码行数:22,代码来源:097_add_services.py

示例14: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def upgrade():
    op.create_table(
        'vpn_endpoint_groups',
        sa.Column('id', sa.String(length=36), nullable=False,
                  primary_key=True),
        sa.Column('tenant_id', sa.String(length=255),
                  index=True),
        sa.Column('name', sa.String(length=255)),
        sa.Column('description', sa.String(length=255)),
        sa.Column('endpoint_type',
                  sa.Enum(constants.SUBNET_ENDPOINT, constants.CIDR_ENDPOINT,
                          constants.VLAN_ENDPOINT, constants.NETWORK_ENDPOINT,
                          constants.ROUTER_ENDPOINT,
                          name='endpoint_type'),
                  nullable=False),
    )
    op.create_table(
        'vpn_endpoints',
        sa.Column('endpoint', sa.String(length=255), nullable=False),
        sa.Column('endpoint_group_id', sa.String(36), nullable=False),
        sa.ForeignKeyConstraint(['endpoint_group_id'],
                                ['vpn_endpoint_groups.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('endpoint', 'endpoint_group_id'),
    ) 
开发者ID:openstack,项目名称:neutron-vpnaas,代码行数:27,代码来源:41b509d10b5e_vpnaas_endpoint_groups.py

示例15: test_enum_detection

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Enum [as 别名]
def test_enum_detection(metadata):
    Table("simple_items", metadata, Column("enum", VARCHAR(255)), CheckConstraint(r"simple_items.enum IN ('A', '\'B', 'C')"))

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

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('enum', Enum('A', "\\\\'B", 'C'))
)
"""
    ) 
开发者ID:thomaxxl,项目名称:safrs,代码行数:20,代码来源:test_codegen.py


注:本文中的sqlalchemy.Enum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。