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


Python sqlalchemy.ForeignKeyConstraint方法代码示例

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


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

示例1: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('citizen_complaint',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('department_id', sa.Integer(), nullable=False),
    sa.Column('opaque_id', sa.String(length=255), nullable=False),
    sa.Column('occured_date', sa.DateTime(), nullable=True),
    sa.Column('division', sa.String(length=255), nullable=True),
    sa.Column('precinct', sa.String(length=255), nullable=True),
    sa.Column('shift', sa.String(length=255), nullable=True),
    sa.Column('beat', sa.String(length=255), nullable=True),
    sa.Column('disposition', sa.String(length=255), nullable=True),
    sa.Column('census_tract', sa.String(length=255), nullable=True),
    sa.Column('resident_race', sa.String(length=255), nullable=True),
    sa.Column('officer_race', sa.String(length=255), nullable=True),
    sa.Column('resident_sex', sa.String(length=255), nullable=True),
    sa.Column('officer_sex', sa.String(length=255), nullable=True),
    sa.Column('officer_identifier', sa.String(length=255), nullable=True),
    sa.Column('officer_years_of_service', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('opaque_id')
    )
    ### end Alembic commands ### 
开发者ID:codeforamerica,项目名称:comport,代码行数:26,代码来源:33fcc9c4867_.py

示例2: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    op.create_table(
        'assaults_on_officers',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('department_id', sa.Integer(), nullable=False),
        sa.Column('opaque_id', sa.String(length=255), nullable=False),
        sa.Column('officer_identifier', sa.String(length=255), nullable=True),
        sa.Column('service_type', sa.String(length=255), nullable=True),
        sa.Column('force_type', sa.String(length=255), nullable=True),
        sa.Column('assignment', sa.String(length=255), nullable=True),
        sa.Column('arrest_made', sa.Boolean(), nullable=True),
        sa.Column('officer_injured', sa.Boolean(), nullable=True),
        sa.Column('officer_killed', sa.Boolean(), nullable=True),
        sa.Column('report_filed', sa.Boolean(), nullable=True),
        sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
        sa.PrimaryKeyConstraint('id')
    ) 
开发者ID:codeforamerica,项目名称:comport,代码行数:19,代码来源:720df9948a25_.py

示例3: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=80), nullable=False),
    sa.Column('email', sa.String(length=80), nullable=False),
    sa.Column('password', sa.String(length=128), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('first_name', sa.String(length=30), nullable=True),
    sa.Column('last_name', sa.String(length=30), nullable=True),
    sa.Column('active', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('username')
    )
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
开发者ID:codeforamerica,项目名称:comport,代码行数:25,代码来源:52979aa7977_.py

示例4: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    op.create_table(
        'container_actions',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('action', sa.String(length=255), nullable=True),
        sa.Column('container_uuid', sa.String(length=36), nullable=False),
        sa.Column('request_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('start_time', sa.DateTime(), nullable=True),
        sa.Column('finish_time', sa.DateTime(), nullable=True),
        sa.Column('message', sa.String(length=255), nullable=True),
        sa.Index('container_uuid_idx', 'container_uuid'),
        sa.Index('request_id_idx', 'request_id'),
        sa.ForeignKeyConstraint(['container_uuid'], ['container.uuid'], ),
        sa.PrimaryKeyConstraint('id')
    ) 
开发者ID:openstack,项目名称:zun,代码行数:21,代码来源:cf46a28f46bc_add_container_actions_table.py

示例5: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    op.create_table(
        'exec_instance',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), primary_key=True, nullable=False),
        sa.Column('container_id', sa.Integer(), nullable=False),
        sa.Column('exec_id', sa.String(255), nullable=False),
        sa.Column('token', sa.String(255), nullable=True),
        sa.Column('url', sa.String(255), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.ForeignKeyConstraint(['container_id'], ['container.id'],
                                ondelete='CASCADE'),
        sa.UniqueConstraint('container_id', 'exec_id',
                            name='uniq_exec_instance0container_id_exec_id'),
    ) 
开发者ID:openstack,项目名称:zun,代码行数:18,代码来源:26896d5f9053_create_exec_instance_table.py

示例6: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    op.create_table(
        'container_actions_events',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('event', sa.String(length=255), nullable=True),
        sa.Column('action_id', sa.Integer(), nullable=False),
        sa.Column('start_time', sa.DateTime(), nullable=True),
        sa.Column('finish_time', sa.DateTime(), nullable=True),
        sa.Column('result', sa.String(length=255), nullable=True),
        sa.Column('traceback', sa.Text(), nullable=True),
        sa.Column('details', sa.Text(), nullable=True),
        sa.ForeignKeyConstraint(['action_id'], ['container_actions.id'], ),
        sa.PrimaryKeyConstraint('id')
    ) 
开发者ID:openstack,项目名称:zun,代码行数:18,代码来源:b6bfca998431_add_container_actions_events_table.py

示例7: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('fingerprint',
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('hostname', sa.String(length=255), nullable=True),
    sa.Column('sha256_fingerprint', sa.String(length=255), nullable=True),
    sa.Column('hashed_hostname', sa.String(length=255), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id', 'hashed_hostname', name='_user_id_hashed_hostname_uc')
    )
    op.create_index(op.f('ix_fingerprint_hashed_hostname'), 'fingerprint', ['hashed_hostname'], unique=False)
    op.create_index(op.f('ix_fingerprint_user_id'), 'fingerprint', ['user_id'], unique=False)
    # ### end Alembic commands ### 
开发者ID:Salamek,项目名称:gitlab-tools,代码行数:19,代码来源:56189bfb2c5f_.py

示例8: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('task_result',
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('pull_mirror_id', sa.Integer(), nullable=True),
    sa.Column('push_mirror_id', sa.Integer(), nullable=True),
    sa.Column('task_id', sa.String(length=155), nullable=True),
    sa.Column('status', sa.String(length=50), nullable=True),
    sa.Column('task_name', sa.String(length=255), nullable=True),
    sa.Column('invoked_by', sa.Integer(), nullable=True),
    sa.Column('result', sa.PickleType(), nullable=True),
    sa.Column('date_done', sa.DateTime(), nullable=True),
    sa.Column('traceback', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['pull_mirror_id'], ['pull_mirror.id'], ),
    sa.ForeignKeyConstraint(['push_mirror_id'], ['push_mirror.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('task_id')
    )
    op.create_index(op.f('ix_task_result_pull_mirror_id'), 'task_result', ['pull_mirror_id'], unique=False)
    op.create_index(op.f('ix_task_result_push_mirror_id'), 'task_result', ['push_mirror_id'], unique=False)
    # ### end Alembic commands ### 
开发者ID:Salamek,项目名称:gitlab-tools,代码行数:25,代码来源:20bcb4b2673c_.py

示例9: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('refused_email',
    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('full_report_path', sa.String(length=128), nullable=False),
    sa.Column('path', sa.String(length=128), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('delete_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('full_report_path'),
    sa.UniqueConstraint('path')
    )
    op.add_column('forward_email_log', sa.Column('refused_email_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'forward_email_log', 'refused_email', ['refused_email_id'], ['id'], ondelete='SET NULL')
    # ### end Alembic commands ### 
开发者ID:simple-login,项目名称:app,代码行数:20,代码来源:2020_031416_11a35b448f83_.py

示例10: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('email_change',
    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('new_email', sa.String(length=128), nullable=False),
    sa.Column('code', sa.String(length=128), nullable=False),
    sa.Column('expired', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('code'),
    sa.UniqueConstraint('new_email')
    )
    op.create_index(op.f('ix_email_change_user_id'), 'email_change', ['user_id'], unique=True)
    # ### end Alembic commands ### 
开发者ID:simple-login,项目名称:app,代码行数:19,代码来源:3ebfbaeb76c0_.py

示例11: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('social_auth',
    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('social', sa.String(length=128), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id', 'social', name='uq_social_auth')
    )
    op.alter_column('users', 'password',
               existing_type=sa.VARCHAR(length=128),
               nullable=True)
    op.alter_column('users', 'salt',
               existing_type=sa.VARCHAR(length=128),
               nullable=True)
    # ### end Alembic commands ### 
开发者ID:simple-login,项目名称:app,代码行数:21,代码来源:2020_022722_75093e7ded27_.py

示例12: downgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('client_scope',
    sa.Column('client_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('scope_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['client_id'], ['client.id'], name='client_scope_client_id_fkey', ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['scope_id'], ['scope.id'], name='client_scope_scope_id_fkey', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('client_id', 'scope_id', name='client_scope_pkey')
    )
    op.create_table('scope',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('name', sa.VARCHAR(length=128), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('id', name='scope_pkey'),
    sa.UniqueConstraint('name', name='scope_name_key')
    )
    # ### end Alembic commands ### 
开发者ID:simple-login,项目名称:app,代码行数:20,代码来源:551c4e6d4a8b_.py

示例13: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [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

示例14: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('fido',
    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('credential_id', sa.String(), nullable=False),
    sa.Column('uuid', sa.String(), nullable=False),
    sa.Column('public_key', sa.String(), nullable=False),
    sa.Column('sign_count', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=False),
    sa.ForeignKeyConstraint(['uuid'], ['users.fido_uuid'], ondelete='cascade'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('public_key')
    )
    op.create_index(op.f('ix_fido_credential_id'), 'fido', ['credential_id'], unique=True)
    op.drop_constraint('users_fido_credential_id_key', 'users', type_='unique')
    op.drop_constraint('users_fido_pk_key', 'users', type_='unique')
    op.drop_column('users', 'fido_sign_count')
    op.drop_column('users', 'fido_pk')
    op.drop_column('users', 'fido_credential_id')
    # ### end Alembic commands ### 
开发者ID:simple-login,项目名称:app,代码行数:24,代码来源:2020_052419_f680032cc361_.py

示例15: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import ForeignKeyConstraint [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('client',
    sa.Column('id', sa.String(length=255), nullable=False),
    sa.Column('homeserver', sa.String(length=255), nullable=False),
    sa.Column('access_token', sa.Text(), nullable=False),
    sa.Column('enabled', sa.Boolean(), nullable=False),
    sa.Column('next_batch', sa.String(length=255), nullable=False),
    sa.Column('filter_id', sa.String(length=255), nullable=False),
    sa.Column('sync', sa.Boolean(), nullable=False),
    sa.Column('autojoin', sa.Boolean(), nullable=False),
    sa.Column('displayname', sa.String(length=255), nullable=False),
    sa.Column('avatar_url', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('plugin',
    sa.Column('id', sa.String(length=255), nullable=False),
    sa.Column('type', sa.String(length=255), nullable=False),
    sa.Column('enabled', sa.Boolean(), nullable=False),
    sa.Column('primary_user', sa.String(length=255), nullable=False),
    sa.Column('config', sa.Text(), nullable=False),
    sa.ForeignKeyConstraint(['primary_user'], ['client.id'], onupdate='CASCADE', ondelete='RESTRICT'),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ### 
开发者ID:maubot,项目名称:maubot,代码行数:27,代码来源:d295f8dcfa64_initial_revision.py


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