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


Python postgresql.JSONB属性代码示例

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


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

示例1: upgrade

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

示例2: upgrade

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('domains', sa.Column('integration_id', sa.String(length=512), nullable=True))
    op.alter_column('domains', 'total_resource_slots',
                    existing_type=postgresql.JSONB(astext_type=sa.Text()),
                    nullable=True)
    op.add_column('groups', sa.Column('integration_id', sa.String(length=512), nullable=True))
    op.add_column('groups', sa.Column('total_resource_slots',
                                      postgresql.JSONB(astext_type=sa.Text()), nullable=True))
    op.add_column('users', sa.Column('integration_id', sa.String(length=512), nullable=True))
    # ### end Alembic commandk ###

    print('\nSet group\'s total_resource_slots with empty dictionary.')
    query = textwrap.dedent('''\
        UPDATE groups SET total_resource_slots = '{}'::jsonb;
    ''')
    connection = op.get_bind()
    connection.execute(query) 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:20,代码来源:22964745c12b_add_total_resource_slots_to_group.py

示例3: upgrade

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('key_value_store',
        sa.Column('id', sa.BigInteger(), nullable=False),
        sa.Column('key', sa.Text(), nullable=False),
        sa.Column('value', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.PrimaryKeyConstraint('id')
    )

    print("Creating index")
    op.create_index(op.f('ix_key_value_store_key'), 'key_value_store', ['key'], unique=True)
    print("Applying not-null constraing")
    op.alter_column('nu_release_item', 'release_date',
               existing_type=postgresql.TIMESTAMP(),
               nullable=False)
    # ### end Alembic commands ### 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:18,代码来源:00042_49308bd51717_kvstore_table.py

示例4: upgrade

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

示例5: upgrade

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('credit_transfer', sa.Column('transfer_metadata', postgresql.JSONB(astext_type=sa.Text()), nullable=True))

    # Create a tempoary "_status" type, convert and drop the "old" type
    tmp_type.create(op.get_bind(), checkfirst=False)
    op.execute('ALTER TABLE credit_transfer ALTER COLUMN transfer_type TYPE _transfertypeenum'
               ' USING transfer_type::text::_transfertypeenum')

    # Convert 'DISBURSEMENT' transfer_type into 'DEPOSIT'
    op.execute(tcr.update().where(tcr.c.transfer_type == u'DISBURSEMENT').values(transfer_type='DEPOSIT'))

    old_type.drop(op.get_bind(), checkfirst=False)
    # Create and convert to the "new" status type
    new_type.create(op.get_bind(), checkfirst=False)
    op.execute('ALTER TABLE credit_transfer ALTER COLUMN transfer_type TYPE transfertypeenum'
               ' USING transfer_type::text::transfertypeenum')
    tmp_type.drop(op.get_bind(), checkfirst=False)
    # ### end Alembic commands ### 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:21,代码来源:1176fec745c0_.py

示例6: upgrade

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def upgrade():
    op.create_table('fda_dap',

        # Meta

        sa.Column('meta_id', sa.Text, unique=True),
        sa.Column('meta_source', sa.Text),
        sa.Column('meta_created', sa.DateTime(timezone=True)),
        sa.Column('meta_updated', sa.DateTime(timezone=True)),

        # General

        sa.Column('id', sa.Text, unique=True),
        sa.Column('documents', JSONB),
        sa.Column('approval_type', sa.Text),
        sa.Column('supplement_number', sa.Integer),
        sa.Column('action_date', sa.Date),
        sa.Column('fda_application_num', sa.Text),
        sa.Column('notes', sa.Text),

    ) 
开发者ID:opentrials,项目名称:collectors,代码行数:23,代码来源:20160725130032_fda_dap_create_table.py

示例7: upgrade

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
    op.create_table('expedition',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('resources_id', sa.Integer(), nullable=True),
    sa.Column('constraints', postgresql.JSONB(), nullable=True),
    sa.ForeignKeyConstraint(['resources_id'], ['resources.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('admiral_j_expedition',
    sa.Column('adm_id', sa.Integer(), nullable=True),
    sa.Column('expedition_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['adm_id'], ['admiral.id'], ),
    sa.ForeignKeyConstraint(['expedition_id'], ['expedition.id'], )
    )
    ### end Alembic commands ### 
开发者ID:KanColleTool,项目名称:kcsrv,代码行数:18,代码来源:ecf3973e1118_add_expedition_table_and_relationship.py

示例8: update_json

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def update_json(self, *args, connection=None, **kwargs):
        t = self.table
        if args:
            if len(args) > 1 and not kwargs:
                field, *path, value = args
            else:
                field, *path = args
                value = kwargs
            for p in reversed(path):
                value = {p: value}
            kwargs = {field: value}
        elif not kwargs:
            raise ValueError('Need args or kwargs')

        await connection.fetchval(
            t.update().where(
                t.c[self.primary_key] == self.pk
            ).values(
                {
                    t.c[field]: sa.func.coalesce(
                        t.c[field], sa.cast({}, JSONB)
                    ) + sa.cast(value, JSONB)
                    for field, value in kwargs.items()
                }
            ).returning(t.c[self.primary_key])) 
开发者ID:dvhb,项目名称:dvhb-hybrid,代码行数:27,代码来源:model.py

示例9: test_compile_jsonb_with_custom_json_encoder

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def test_compile_jsonb_with_custom_json_encoder():
    jsonb_table = sa.Table(
        'meowsb', sa.MetaData(),
        sa.Column('data', postgresql.JSONB),
    )

    class JSONEncoder(json.JSONEncoder):
        def default(self, o):
            if isinstance(o, uuid.UUID):
                return str(o)
            else:
                return super().default(o)

    dialect = connection.get_dialect(
        json_serializer=partial(json.dumps, cls=JSONEncoder)
    )

    data = {
        'uuid4': uuid.uuid4(),
    }
    query = jsonb_table.insert().values(data=data)
    q, p = connection.compile_query(query, dialect=dialect)
    assert q == 'INSERT INTO meowsb (data) VALUES ($1)'
    assert p == ['{"uuid4": "%s"}' % data['uuid4']] 
开发者ID:CanopyTax,项目名称:asyncpgsa,代码行数:26,代码来源:test_connection.py

示例10: upgrade

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def upgrade():
    op.add_column(
        'dataset',
        sa.Column(
            'meta',
            postgresql.JSONB(),
            nullable=True
        )
    )
    op.execute('''
        UPDATE "dataset" SET
            meta = jsonb_set(coalesce(meta, '{}'), '{organization_id}', to_jsonb(organization_id))
        WHERE
            organization_id IS NOT NULL
    ''')
    op.drop_column('dataset', 'organization_id') 
开发者ID:planbrothers,项目名称:ml-annotate,代码行数:18,代码来源:889fee1f3c80_add_meta_to_dataset.py

示例11: upgrade

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('kernels', sa.Column('attached_devices',
                                       postgresql.JSONB(astext_type=sa.Text()),
                                       nullable=True))
    # ### end Alembic commands ### 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:8,代码来源:9c89b9011872_add_attached_devices_field_in_kernels.py

示例12: downgrade

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('users', 'integration_id')
    op.drop_column('groups', 'total_resource_slots')
    op.drop_column('groups', 'integration_id')
    op.alter_column('domains', 'total_resource_slots',
                    existing_type=postgresql.JSONB(astext_type=sa.Text()),
                    nullable=False)
    op.drop_column('domains', 'integration_id')
    # ### end Alembic commands ### 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:12,代码来源:22964745c12b_add_total_resource_slots_to_group.py

示例13: upgrade

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def upgrade():
    op.add_column('kernels', sa.Column('mount_map', pgsql.JSONB(), nullable=True, default={})) 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:4,代码来源:d452bacd085c_add_mount_map_column_to_kernel.py

示例14: upgrade

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('kernels', sa.Column('internal_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
    # ### end Alembic commands ### 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:6,代码来源:202b6dcbc159_add_internal_data_to_kernels.py

示例15: upgrade

# 需要导入模块: from sqlalchemy.dialects import postgresql [as 别名]
# 或者: from sqlalchemy.dialects.postgresql import JSONB [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('kernels', sa.Column('resource_opts',
                                       postgresql.JSONB(astext_type=sa.Text()),
                                       nullable=True))
    # ### end Alembic commands ### 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:8,代码来源:5b45f28d2cac_add_resource_opts_in_kernels.py


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