本文整理汇总了Python中sqlalchemy.Boolean方法的典型用法代码示例。如果您正苦于以下问题:Python sqlalchemy.Boolean方法的具体用法?Python sqlalchemy.Boolean怎么用?Python sqlalchemy.Boolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy
的用法示例。
在下文中一共展示了sqlalchemy.Boolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [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')
)
示例2: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [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 ###
示例3: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [as 别名]
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')
)
示例4: create_volume_table
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [as 别名]
def create_volume_table():
op.create_table(
'volume',
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('uuid', sa.String(36), nullable=False),
sa.Column('project_id', sa.String(length=255), nullable=True),
sa.Column('user_id', sa.String(length=255), nullable=True),
sa.Column('cinder_volume_id', sa.String(36), nullable=True),
sa.Column('volume_provider', sa.String(36), nullable=False),
sa.Column('connection_info', MediumText(), nullable=True),
sa.Column('host', sa.String(length=255), nullable=True),
sa.Column('auto_remove', sa.Boolean(), default=False, nullable=True),
sa.Column('contents', MediumText(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('uuid', name='uniq_volume0uuid'),
)
示例5: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [as 别名]
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('mailbox',
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('email', sa.String(length=256), nullable=False),
sa.Column('verified', sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
)
op.add_column('gen_email', sa.Column('mailbox_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'gen_email', 'mailbox', ['mailbox_id'], ['id'], ondelete='cascade')
# ### end Alembic commands ###
示例6: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [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 ###
示例7: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [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),
)
示例8: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [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)
)
示例9: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [as 别名]
def upgrade():
op.add_column('watchers', sa.Column('watch_commits', sa.Boolean(),
nullable=True))
op.add_column('watchers', sa.Column('watch_issues', sa.Boolean(),
nullable=True))
# This section is to update the `watch_issues` and `watch_commits` columns
# with the value of `watch`
connection = op.get_bind()
for watcher in connection.execute(watcher_helper.select()):
connection.execute(
watcher_helper.update().where(
watcher_helper.c.id == watcher.id
).values(
watch_issues=watcher.watch,
watch_commits=False
)
)
with op.batch_alter_table('watchers') as b:
# Set nullable to False now that we've set values
b.alter_column('watch_issues', nullable=False)
b.alter_column('watch_commits', nullable=False)
# Remove the watch column
b.drop_column('watch')
示例10: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [as 别名]
def upgrade():
''' Add is_fork column to project table'''
op.add_column(
'projects',
sa.Column(
'is_fork', sa.Boolean,
default=False,
nullable=True)
)
op.execute('''UPDATE "projects" '''
'''SET is_fork=TRUE WHERE parent_id IS NOT NULL;''')
op.execute('''UPDATE "projects" '''
'''SET is_fork=FALSE WHERE parent_id IS NULL;''')
op.alter_column(
'projects', 'is_fork',
nullable=False, existing_nullable=True)
示例11: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [as 别名]
def upgrade():
''' Add active_commit column to hook_pagure_ci table'''
op.add_column(
'hook_pagure_ci',
sa.Column('active_commit', sa.Boolean, nullable=True, default=False)
)
op.add_column(
'hook_pagure_ci',
sa.Column('active_pr', sa.Boolean, nullable=True, default=False)
)
op.execute('UPDATE hook_pagure_ci SET active_pr=active')
op.execute('UPDATE hook_pagure_ci SET active_commit=False')
op.alter_column(
'hook_pagure_ci', 'active_pr',
nullable=False, existing_nullable=True)
op.alter_column(
'hook_pagure_ci', 'active_commit',
nullable=False, existing_nullable=True)
示例12: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [as 别名]
def upgrade():
''' Add a column to mark a project read only '''
op.add_column(
'projects',
sa.Column(
'read_only',
sa.Boolean,
default=True,
nullable=True,
)
)
op.execute(''' UPDATE projects SET read_only=False ''')
op.alter_column(
'projects',
'read_only',
nullable=False,
existing_nullable=True
)
示例13: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('demographic_values',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('department_id', sa.Integer(), nullable=False),
sa.Column('race', sa.String(length=255), nullable=True),
sa.Column('gender', sa.String(length=255), nullable=True),
sa.Column('count', sa.Integer(), nullable=True),
sa.Column('department_value', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
sa.PrimaryKeyConstraint('id')
)
### end Alembic commands ###
示例14: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [as 别名]
def upgrade():
# create the has_disposition column
op.add_column('officer_involved_shootings_bpd', sa.Column('has_disposition', sa.Boolean(), nullable=True))
# update the has_disposition column based on values in the disposition column
db_bind = op.get_bind()
db_bind.execute(sa.sql.text('''
UPDATE officer_involved_shootings_bpd SET has_disposition = (disposition != '' AND disposition IS NOT NULL)
'''))
# drop the disposition column
op.drop_column('officer_involved_shootings_bpd', 'disposition')
示例15: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Boolean [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('use_of_force_incidents', sa.Column('beat', sa.String(length=255), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('division', sa.String(length=255), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('office_weapon_used', sa.String(length=255), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('officer_force_type', sa.String(length=255), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('officer_race', sa.String(length=255), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('precinct', sa.String(length=255), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('resident_hospitalized', sa.Boolean(), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('resident_injured', sa.Boolean(), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('resident_race', sa.String(length=255), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('resident_resist_type', sa.String(length=255), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('resident_weapon_used', sa.String(length=255), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('shift', sa.String(length=255), nullable=True))
op.alter_column('use_of_force_incidents', 'department_id',
existing_type=sa.INTEGER(),
nullable=False)
op.drop_column('use_of_force_incidents', 'month')
op.drop_column('use_of_force_incidents', 'hour')
op.drop_column('use_of_force_incidents', 'year')
op.drop_column('use_of_force_incidents', 'citizen_hospitalized')
op.drop_column('use_of_force_incidents', 'citizen_weapon')
op.drop_column('use_of_force_incidents', 'citizen_injured')
op.drop_column('use_of_force_incidents', 'received_date')
op.drop_column('use_of_force_incidents', 'day_of_week')
op.drop_column('use_of_force_incidents', 'status')
### end Alembic commands ###