當前位置: 首頁>>代碼示例>>Python>>正文


Python postgresql.JSON屬性代碼示例

本文整理匯總了Python中sqlalchemy.dialects.postgresql.JSON屬性的典型用法代碼示例。如果您正苦於以下問題:Python postgresql.JSON屬性的具體用法?Python postgresql.JSON怎麽用?Python postgresql.JSON使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在sqlalchemy.dialects.postgresql的用法示例。


在下文中一共展示了postgresql.JSON屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: upgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def upgrade():

    op.create_table('monthly_billing',
                    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
                    sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
                    sa.Column('month', sa.String(), nullable=False),
                    sa.Column('year', sa.Float(), nullable=False),
                    sa.Column('notification_type',
                              postgresql.ENUM('email', 'sms', 'letter', name='notification_type', create_type=False),
                              nullable=False),
                    sa.Column('monthly_totals', postgresql.JSON(), nullable=False),
                    sa.Column('updated_at', sa.DateTime, nullable=False),
                    sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_index(op.f('ix_monthly_billing_service_id'), 'monthly_billing', ['service_id'], unique=False)
    op.create_index(op.f('uix_monthly_billing'), 'monthly_billing', ['service_id', 'month', 'year', 'notification_type'], unique=True) 
開發者ID:alphagov,項目名稱:notifications-api,代碼行數:19,代碼來源:0110_monthly_billing.py

示例2: downgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('monthly_billing',
    sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('service_id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('notification_type', postgresql.ENUM('email', 'sms', 'letter', name='notification_type'), autoincrement=False, nullable=False),
    sa.Column('monthly_totals', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=False),
    sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.Column('start_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.Column('end_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['service_id'], ['services.id'], name='monthly_billing_service_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='monthly_billing_pkey'),
    sa.UniqueConstraint('service_id', 'start_date', 'notification_type', name='uix_monthly_billing')
    )
    op.create_index('ix_monthly_billing_service_id', 'monthly_billing', ['service_id'], unique=False)
    # ### end Alembic commands ### 
開發者ID:alphagov,項目名稱:notifications-api,代碼行數:18,代碼來源:0210_remove_monthly_billing.py

示例3: test_json

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def test_json(self):
        Base = declarative_base()

        class J(Base):
            __tablename__ = "j"
            id = Column("id", Integer, primary_key=True)
            json = Column("_json", JSON, default={})
            field = index_property("json", "field")

        j = J(json={"a": 1, "b": 2})
        assert_raises(AttributeError, lambda: j.field)
        j.field = "test"
        eq_(j.field, "test")
        eq_(j.json, {"a": 1, "b": 2, "field": "test"})

        j2 = J(field="test")
        eq_(j2.json, {"field": "test"})
        eq_(j2.field, "test") 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:20,代碼來源:test_indexable.py

示例4: test_get_default_value

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def test_get_default_value(self):
        Base = declarative_base()

        class J(Base):
            __tablename__ = "j"
            id = Column(Integer, primary_key=True)
            json = Column(JSON, default={})
            default = index_property("json", "field", default="default")
            none = index_property("json", "field", default=None)

        j = J()
        assert j.json is None

        assert j.default == "default"
        assert j.none is None
        j.json = {}
        assert j.default == "default"
        assert j.none is None
        j.default = None
        assert j.default is None
        assert j.none is None
        j.none = 10
        assert j.default == 10
        assert j.none == 10 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:26,代碼來源:test_indexable.py

示例5: bind_expression

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def bind_expression(self, value):
        return cast(value, sqltypes.JSON) 
開發者ID:chanzuckerberg,項目名稱:sqlalchemy-aurora-data-api,代碼行數:4,代碼來源:__init__.py

示例6: upgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('feed_post_meta',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('contentid', sa.Text(), nullable=False),
    sa.Column('meta', JSON(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_feed_post_meta_contentid'), 'feed_post_meta', ['contentid'], unique=True)
    ### end Alembic commands ### 
開發者ID:fake-name,項目名稱:ReadableWebProxy,代碼行數:12,代碼來源:00033_53fab90468f4_.py

示例7: upgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('user', sa.Column('matched_profile_pictures', postgresql.JSON(astext_type=sa.Text()), nullable=True))
    # ### end Alembic commands ### 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:6,代碼來源:47c9e8260c4d_.py

示例8: upgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('ussd_menu',
    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('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('parent_id', sa.Integer(), nullable=True),
    sa.Column('display_key', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_ussd_menu_name'), 'ussd_menu', ['name'], unique=True)
    op.create_table('ussd_session',
    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('session_id', sa.String(), nullable=False),
    sa.Column('service_code', sa.String(), nullable=False),
    sa.Column('msisdn', sa.String(), nullable=False),
    sa.Column('user_input', sa.String(), nullable=True),
    sa.Column('state', sa.String(), nullable=False),
    sa.Column('session_data', postgresql.JSON(astext_type=sa.Text()), nullable=True),
    sa.Column('ussd_menu_id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['ussd_menu_id'], ['ussd_menu.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_ussd_session_session_id'), 'ussd_session', ['session_id'], unique=True)
    op.drop_index('ix_ussd_sessions_session_id', table_name='ussd_sessions')
    op.drop_table('ussd_sessions')
    op.drop_index('ix_ussd_menus_name', table_name='ussd_menus')
    op.drop_table('ussd_menus')
    # ### end Alembic commands ### 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:39,代碼來源:5f4b4c9f586d_.py

示例9: downgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('ussd_menus',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('description', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('parent_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('display_key', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('id', name='ussd_menus_pkey')
    )
    op.create_index('ix_ussd_menus_name', 'ussd_menus', ['name'], unique=True)
    op.create_table('ussd_sessions',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('session_id', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('service_code', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('msisdn', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('user_input', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('ussd_menu_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('state', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('session_data', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='ussd_sessions_pkey')
    )
    op.create_index('ix_ussd_sessions_session_id', 'ussd_sessions', ['session_id'], unique=True)
    op.drop_index(op.f('ix_ussd_session_session_id'), table_name='ussd_session')
    op.drop_table('ussd_session')
    op.drop_index(op.f('ix_ussd_menu_name'), table_name='ussd_menu')
    op.drop_table('ussd_menu')
    # ### end Alembic commands ### 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:37,代碼來源:5f4b4c9f586d_.py

示例10: downgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('user', sa.Column('custom_attributes', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True))
    op.drop_column('user', 'preferred_language')
    op.drop_table('custom_attribute_user_storage')
    # ### end Alembic commands ### 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:8,代碼來源:35aa30ce8a33_.py

示例11: upgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('transfer_usage',
    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('name', sa.String(), nullable=True),
    sa.Column('translations', postgresql.JSON(astext_type=sa.Text()), nullable=True),
    sa.Column('icon', sa.String(), nullable=True),
    sa.Column('priority', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ### 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:16,代碼來源:7550bc658dc5_.py

示例12: upgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('kyc_application', sa.Column('kyc_actions', postgresql.JSON(astext_type=sa.Text()), nullable=True))
    op.add_column('kyc_application', sa.Column('trulioo_id', sa.String(), nullable=True))
    op.add_column('kyc_application', sa.Column('user_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'kyc_application', 'user', ['user_id'], ['id'])
    # ### end Alembic commands ### 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:9,代碼來源:fe36052e1fa5_.py

示例13: upgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('user', sa.Column('custom_attributes', postgresql.JSON(astext_type=sa.Text()), nullable=True))
    # ### end Alembic commands ### 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:6,代碼來源:7580066bfb5c_.py

示例14: upgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('ussd_menus',
    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('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('parent_id', sa.Integer(), nullable=True),
    sa.Column('display_text_en', sa.String(), nullable=False),
    sa.Column('display_text_sw', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_ussd_menus_name'), 'ussd_menus', ['name'], unique=True)
    op.create_table('ussd_sessions',
    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('session_id', sa.String(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('service_code', sa.String(), nullable=False),
    sa.Column('msisdn', sa.String(), nullable=False),
    sa.Column('user_input', sa.String(), nullable=True),
    sa.Column('ussd_menu_id', sa.Integer(), nullable=False),
    sa.Column('state', sa.String(), nullable=False),
    sa.Column('sessions_data', postgresql.JSON(astext_type=sa.Text()), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_ussd_sessions_session_id'), 'ussd_sessions', ['session_id'], unique=True)
    # ### end Alembic commands ### 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:34,代碼來源:1a8a9213e85d_.py

示例15: upgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import JSON [as 別名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('saved_filter',
    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('name', sa.String(), nullable=True),
    sa.Column('filter', postgresql.JSON(astext_type=sa.Text()), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.add_column('user', sa.Column('_is_view', sa.Boolean(), nullable=True))
    # ### end Alembic commands ### 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:15,代碼來源:4688c879cae3_.py


注:本文中的sqlalchemy.dialects.postgresql.JSON屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。