本文整理匯總了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)
示例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 ###
示例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")
示例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
示例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)
示例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 ###
示例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 ###
示例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 ###
示例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 ###
示例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 ###
示例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 ###
示例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 ###
示例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 ###
示例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 ###
示例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 ###