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


Python sqlalchemy.NUMERIC属性代码示例

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


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

示例1: downgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def downgrade():
    connection = op.get_bind()
    if connection.engine.name != 'sqlite':
        return
    
    with op.batch_alter_table('user') as batch_op:
        batch_op.add_column(sa.Column('_password',
               type_=sa.NUMERIC(precision=128),
               server_default='',
               nullable=False
            ))
    
    connection.execute(
            UserHelper.update().values(_password=UserHelper.c.password)
        )
    
    with op.batch_alter_table('user') as batch_op:
        batch_op.drop_column('password')
        batch_op.alter_column('_password', server_default=None, new_column_name='password') 
开发者ID:frol,项目名称:flask-restplus-server-example,代码行数:21,代码来源:beb065460c24_fixed-password-type.py

示例2: downgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def downgrade():
    op.drop_table('letter_rates')
    op.create_table('letter_rates',
                    sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
                    sa.Column('valid_from', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
                    sa.PrimaryKeyConstraint('id', name='letter_rates_pkey'),
                    postgresql_ignore_search_path=False
                    )
    op.create_table('letter_rate_details',
                    sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
                    sa.Column('letter_rate_id', postgresql.UUID(), autoincrement=False, nullable=False),
                    sa.Column('page_total', sa.INTEGER(), autoincrement=False, nullable=False),
                    sa.Column('rate', sa.NUMERIC(), autoincrement=False, nullable=False),
                    sa.ForeignKeyConstraint(['letter_rate_id'], ['letter_rates.id'],
                                            name='letter_rate_details_letter_rate_id_fkey'),
                    sa.PrimaryKeyConstraint('id', name='letter_rate_details_pkey')
                    ) 
开发者ID:alphagov,项目名称:notifications-api,代码行数:19,代码来源:0151_refactor_letter_rates.py

示例3: downgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("stores", "default_currency")
    op.drop_column("invoices", "currency")
    op.alter_column(
        "invoices",
        column_name="price",
        new_column_name="amount",
        existing_type=sa.NUMERIC(precision=16, scale=8),
        existing_nullable=False,
        existing_server_default=None,
    )
    op.alter_column(
        "products",
        column_name="price",
        new_column_name="amount",
        existing_type=sa.NUMERIC(precision=16, scale=8),
        existing_nullable=False,
        existing_server_default=None,
    )
    # ### end Alembic commands ### 
开发者ID:MrNaif2018,项目名称:bitcart,代码行数:23,代码来源:771be83a8b87_add_invoice_fiat_currencies.py

示例4: _log

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def _log(t, expr):
    arg, base = expr.op().args
    sa_arg = t.translate(arg)
    if base is not None:
        sa_base = t.translate(base)
        return sa.cast(
            sa.func.log(
                sa.cast(sa_base, sa.NUMERIC), sa.cast(sa_arg, sa.NUMERIC)
            ),
            t.get_sqla_type(expr.type()),
        )
    return sa.func.ln(sa_arg) 
开发者ID:ibis-project,项目名称:ibis,代码行数:14,代码来源:compiler.py

示例5: _round

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def _round(t, expr):
    arg, digits = expr.op().args
    sa_arg = t.translate(arg)

    if digits is None:
        return sa.func.round(sa_arg)

    # postgres doesn't allow rounding of double precision values to a specific
    # number of digits (though simple truncation on doubles is allowed) so
    # we cast to numeric and then cast back if necessary
    result = sa.func.round(sa.cast(sa_arg, sa.NUMERIC), t.translate(digits))
    if digits is not None and isinstance(arg.type(), dt.Decimal):
        return result
    result = sa.cast(result, sa.dialects.postgresql.DOUBLE_PRECISION())
    return result 
开发者ID:ibis-project,项目名称:ibis,代码行数:17,代码来源:compiler.py

示例6: _mod

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def _mod(t, expr):
    left, right = map(t.translate, expr.op().args)

    # postgres doesn't allow modulus of double precision values, so upcast and
    # then downcast later if necessary
    if not isinstance(expr.type(), dt.Integer):
        left = sa.cast(left, sa.NUMERIC)
        right = sa.cast(right, sa.NUMERIC)

    result = left % right
    if expr.type().equals(dt.double):
        return sa.cast(result, sa.dialects.postgresql.DOUBLE_PRECISION())
    else:
        return result 
开发者ID:ibis-project,项目名称:ibis,代码行数:16,代码来源:compiler.py

示例7: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def upgrade():
    op.alter_column('ft_billing', 'billable_units',
                    existing_type=sa.NUMERIC(),
                    type_=sa.Integer(),
                    existing_nullable=True)
    op.alter_column('ft_billing', 'rate_multiplier',
                    existing_type=sa.NUMERIC(),
                    type_=sa.Integer()) 
开发者ID:alphagov,项目名称:notifications-api,代码行数:10,代码来源:0189_ft_billing_data_type.py

示例8: downgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def downgrade():
    op.alter_column('ft_billing', 'rate_multiplier',
                    existing_type=sa.Integer(),
                    type_=sa.NUMERIC())
    op.alter_column('ft_billing', 'billable_units',
                    existing_type=sa.Integer(),
                    type_=sa.NUMERIC(),
                    existing_nullable=True) 
开发者ID:alphagov,项目名称:notifications-api,代码行数:10,代码来源:0189_ft_billing_data_type.py

示例9: downgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('sales_order_line', sa.Column('original_amount', sa.NUMERIC(precision=8, scale=2), autoincrement=False, nullable=True))
    op.add_column('sales_order_line', sa.Column('adjust_amount', sa.NUMERIC(precision=8, scale=2), autoincrement=False, nullable=True))
    op.add_column('sales_order_line', sa.Column('actual_amount', sa.NUMERIC(precision=8, scale=2), autoincrement=False, nullable=True))
    op.drop_table('preference')
    ### end Alembic commands ### 
开发者ID:betterlife,项目名称:betterlifepsi,代码行数:9,代码来源:02_251c5e751233_.py

示例10: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('enum_values', 'code',
               existing_type=sa.VARCHAR(length=32),
               nullable=False)
    op.alter_column('product', 'purchase_price',
               existing_type=sa.NUMERIC(precision=8, scale=2),
               nullable=False)
    op.alter_column('product', 'retail_price',
               existing_type=sa.NUMERIC(precision=8, scale=2),
               nullable=False)
    ### end Alembic commands ### 
开发者ID:betterlife,项目名称:betterlifepsi,代码行数:14,代码来源:03_29b31f4d8de6_.py

示例11: downgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('product', 'retail_price',
               existing_type=sa.NUMERIC(precision=8, scale=2),
               nullable=True)
    op.alter_column('product', 'purchase_price',
               existing_type=sa.NUMERIC(precision=8, scale=2),
               nullable=True)
    op.alter_column('enum_values', 'code',
               existing_type=sa.VARCHAR(length=32),
               nullable=True)
    ### end Alembic commands ### 
开发者ID:betterlife,项目名称:betterlifepsi,代码行数:14,代码来源:03_29b31f4d8de6_.py

示例12: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "invoices", sa.Column("currency", sa.Text(), nullable=True, server_default="USD")
    )
    op.add_column(
        "stores",
        sa.Column("default_currency", sa.Text(), nullable=True, server_default="USD"),
    )
    op.alter_column("invoices", "currency", server_default=None)
    op.alter_column("stores", "default_currency", server_default=None)
    op.alter_column(
        "invoices",
        column_name="amount",
        new_column_name="price",
        existing_type=sa.NUMERIC(precision=16, scale=8),
        existing_nullable=False,
        existing_server_default=None,
    )
    op.alter_column(
        "products",
        column_name="amount",
        new_column_name="price",
        existing_type=sa.NUMERIC(precision=16, scale=8),
        existing_nullable=False,
        existing_server_default=None,
    )
    # ### end Alembic commands ### 
开发者ID:MrNaif2018,项目名称:bitcart,代码行数:30,代码来源:771be83a8b87_add_invoice_fiat_currencies.py

示例13: test_typedecorator_impl

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def test_typedecorator_impl(self):
        for impl_, exp, kw in [
            (Float, "FLOAT", {}),
            (Float, "FLOAT(2)", {"precision": 2}),
            (Float(2), "FLOAT(2)", {"precision": 4}),
            (Numeric(19, 2), "NUMERIC(19, 2)", {}),
        ]:
            for dialect_ in (
                dialects.postgresql,
                dialects.mssql,
                dialects.mysql,
            ):
                dialect_ = dialect_.dialect()

                raw_impl = types.to_instance(impl_, **kw)

                class MyType(types.TypeDecorator):
                    impl = impl_

                dec_type = MyType(**kw)

                eq_(dec_type.impl.__class__, raw_impl.__class__)

                raw_dialect_impl = raw_impl.dialect_impl(dialect_)
                dec_dialect_impl = dec_type.dialect_impl(dialect_)
                eq_(dec_dialect_impl.__class__, MyType)
                eq_(
                    raw_dialect_impl.__class__, dec_dialect_impl.impl.__class__
                )

                self.assert_compile(MyType(**kw), exp, dialect=dialect_) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:33,代码来源:test_types.py

示例14: test_numeric_plain

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def test_numeric_plain(self):
        self.assert_compile(types.NUMERIC(), "NUMERIC") 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:4,代码来源:test_types.py

示例15: test_numeric_precision

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import NUMERIC [as 别名]
def test_numeric_precision(self):
        self.assert_compile(types.NUMERIC(2), "NUMERIC(2)") 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:4,代码来源:test_types.py


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