Python sqlalchemy 模块,JSON 实例源码

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

项目:dcc-dashboard-service    作者:BD2KGenomics    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('billing', sa.Column('cost_by_analysis', sa.JSON(), nullable=True))
    op.alter_column('billing', 'compute_cost',
               existing_type=sa.NUMERIC(),
               nullable=False)
    op.alter_column('billing', 'storage_cost',
               existing_type=sa.NUMERIC(),
               nullable=False)
    ### end Alembic commands ###
项目:dpr-api    作者:oki-archive    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('publisher',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('name', sa.TEXT(), nullable=False),
    sa.Column('title', sa.Text(), nullable=True),
    sa.Column('private', sa.BOOLEAN(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_publisher_name'), 'publisher', ['name'], unique=True)
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('email', sa.TEXT(), nullable=True),
    sa.Column('secret', sa.TEXT(), nullable=True),
    sa.Column('name', sa.TEXT(), nullable=False),
    sa.Column('full_name', sa.TEXT(), nullable=True),
    sa.Column('auth0_id', sa.TEXT(), nullable=True),
    sa.Column('sysadmin', sa.BOOLEAN(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_auth0_id'), 'user', ['auth0_id'], unique=False)
    op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=False)
    op.create_index(op.f('ix_user_name'), 'user', ['name'], unique=True)
    op.create_table('package',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('name', sa.TEXT(), nullable=True),
    sa.Column('descriptor', sa.JSON(), nullable=True),
    sa.Column('status', sa.TEXT(), nullable=True),
    sa.Column('private', sa.BOOLEAN(), nullable=True),
    sa.Column('readme', sa.TEXT(), nullable=True),
    sa.Column('publisher_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['publisher_id'], [u'publisher.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'publisher_id')
    )
    op.create_index(op.f('ix_package_name'), 'package', ['name'], unique=False)
    op.create_index(op.f('ix_package_status'), 'package', ['status'], unique=False)
    op.create_table('publisher_user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('publisher_id', sa.Integer(), nullable=False),
    sa.Column('role', sa.TEXT(), nullable=False),
    sa.ForeignKeyConstraint(['publisher_id'], [u'publisher.id'], ),
    sa.ForeignKeyConstraint(['user_id'], [u'user.id'], ),
    sa.PrimaryKeyConstraint('id', 'user_id', 'publisher_id')
    )
    ### end Alembic commands ###