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


Python postgresql.DOUBLE_PRECISION屬性代碼示例

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


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

示例1: test_column_adaptation

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def test_column_adaptation(metadata):
    Table("simple_items", metadata, Column("id", postgresql.BIGINT), Column("length", postgresql.DOUBLE_PRECISION))

    assert (
        generate_code(metadata)
        == """\
# coding: utf-8
from sqlalchemy import BigInteger, Column, Float, MetaData, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('id', BigInteger),
    Column('length', Float)
)
"""
    ) 
開發者ID:thomaxxl,項目名稱:safrs,代碼行數:21,代碼來源:test_codegen.py

示例2: test_arrays_pg

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def test_arrays_pg(self, connection):
        metadata = self.metadata
        t1 = Table(
            "t",
            metadata,
            Column("x", postgresql.ARRAY(Float)),
            Column("y", postgresql.ARRAY(REAL)),
            Column("z", postgresql.ARRAY(postgresql.DOUBLE_PRECISION)),
            Column("q", postgresql.ARRAY(Numeric)),
        )
        metadata.create_all()
        connection.execute(
            t1.insert(), x=[5], y=[5], z=[6], q=[decimal.Decimal("6.4")]
        )
        row = connection.execute(t1.select()).first()
        eq_(row, ([5], [5], [6], [decimal.Decimal("6.4")])) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:18,代碼來源:test_types.py

示例3: test_arrays_base

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def test_arrays_base(self, connection):
        metadata = self.metadata
        t1 = Table(
            "t",
            metadata,
            Column("x", sqltypes.ARRAY(Float)),
            Column("y", sqltypes.ARRAY(REAL)),
            Column("z", sqltypes.ARRAY(postgresql.DOUBLE_PRECISION)),
            Column("q", sqltypes.ARRAY(Numeric)),
        )
        metadata.create_all()
        connection.execute(
            t1.insert(), x=[5], y=[5], z=[6], q=[decimal.Decimal("6.4")]
        )
        row = connection.execute(t1.select()).first()
        eq_(row, ([5], [5], [6], [decimal.Decimal("6.4")])) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:18,代碼來源:test_types.py

示例4: downgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('currency_conversion', sa.Column('usd_equiv', postgresql.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
    op.drop_column('currency_conversion', 'rate')
    # ### end Alembic commands ### 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:7,代碼來源:96862ec4ff72_.py

示例5: downgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('transfer_account', sa.Column('lat', postgresql.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
    op.add_column('transfer_account', sa.Column('_location', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.add_column('transfer_account', sa.Column('lng', postgresql.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
    op.drop_column('transfer_account', 'is_beneficiary')
    # ### end Alembic commands ### 
開發者ID:teamsempo,項目名稱:SempoBlockchain,代碼行數:9,代碼來源:7036c1830a21_.py

示例6: downgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("user_posts", "permalink_url")
    op.add_column(
        "song",
        sa.Column(
            "yt_popularity",
            postgresql.DOUBLE_PRECISION(precision=53),
            autoincrement=False,
            nullable=True,
        ),
    )
    op.drop_column("song", "custom_popularity")
    # ### end Alembic commands ### 
開發者ID:lttkgp,項目名稱:C-3PO,代碼行數:16,代碼來源:e3a414cf0342_add_custom_popularity.py

示例7: _round

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [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

示例8: _mod

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [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

示例9: upgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('rating', 'sigma',
               existing_type=postgresql.DOUBLE_PRECISION(precision=53),
               nullable=True)
    ### end Alembic commands ### 
開發者ID:usgo,項目名稱:online-ratings,代碼行數:8,代碼來源:01e860788b42_change_sigma_to_nullable.py

示例10: downgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('rating', 'sigma',
               existing_type=postgresql.DOUBLE_PRECISION(precision=53),
               nullable=False)
    ### end Alembic commands ### 
開發者ID:usgo,項目名稱:online-ratings,代碼行數:8,代碼來源:01e860788b42_change_sigma_to_nullable.py

示例11: downgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def downgrade():
    op.add_column('monthly_billing', sa.Column('month', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.add_column(
        'monthly_billing',
        sa.Column('year', postgresql.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True)
    )
    op.drop_constraint('uix_monthly_billing', 'monthly_billing', type_='unique')
    op.create_index(
        'uix_monthly_billing', 'monthly_billing', ['service_id', 'start_date', 'notification_type'], unique=True
    ) 
開發者ID:alphagov,項目名稱:notifications-api,代碼行數:12,代碼來源:0114_drop_monthly_billing_cols.py

示例12: downgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('rc_name_type_patrolled_timestamp', table_name='recentchanges')
    op.add_column('page', sa.Column('page_random', postgresql.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False))
    op.create_index('page_random', 'page', ['page_random'], unique=False)
    # ### end Alembic commands ### 
開發者ID:lahwaacz,項目名稱:wiki-scripts,代碼行數:8,代碼來源:33ef5ceb8902_new_index_for_recentchanges_and_remove_.py

示例13: special_types_table

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def special_types_table(self, metadata):

        # create these types so that we can issue
        # special SQL92 INTERVAL syntax
        class y2m(types.UserDefinedType, postgresql.INTERVAL):
            def get_col_spec(self):
                return "INTERVAL YEAR TO MONTH"

        class d2s(types.UserDefinedType, postgresql.INTERVAL):
            def get_col_spec(self):
                return "INTERVAL DAY TO SECOND"

        table = Table(
            "sometable",
            metadata,
            Column("id", postgresql.UUID, primary_key=True),
            Column("flag", postgresql.BIT),
            Column("bitstring", postgresql.BIT(4)),
            Column("addr", postgresql.INET),
            Column("addr2", postgresql.MACADDR),
            Column("price", postgresql.MONEY),
            Column("addr3", postgresql.CIDR),
            Column("doubleprec", postgresql.DOUBLE_PRECISION),
            Column("plain_interval", postgresql.INTERVAL),
            Column("year_interval", y2m()),
            Column("month_interval", d2s()),
            Column("precision_interval", postgresql.INTERVAL(precision=3)),
            Column("tsvector_document", postgresql.TSVECTOR),
        )

        return table 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:33,代碼來源:test_types.py

示例14: downgrade

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('label_event', sa.Column('label', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('dataset', sa.Column('probability', postgresql.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
    op.add_column('problem', sa.Column('label', sa.Unicode(length=255), nullable=True))

    op.execute('''
        UPDATE label_event SET label = (SELECT label FROM problem_label WHERE problem_label.id = label_event.label_id)
    ''')
    op.execute('''
        UPDATE dataset SET probability = (SELECT probability FROM dataset_label_probability WHERE dataset_label_probability.data_id = dataset.id)
    ''')
    op.execute('''
        UPDATE problem SET label = (SELECT label FROM problem_label WHERE problem_label.problem_id = problem.id)
    ''')

    op.alter_column('label_event', 'label', nullable=False)
    op.alter_column('problem', 'label', nullable=False)

    op.drop_column('problem', 'name')
    op.drop_index(op.f('ix_label_event_label_id'), table_name='label_event')
    op.drop_column('label_event', 'label_id')
    op.drop_index(op.f('ix_dataset_label_probability_label_id'), table_name='dataset_label_probability')
    op.drop_index(op.f('ix_dataset_label_probability_data_id'), table_name='dataset_label_probability')
    op.drop_table('dataset_label_probability')
    op.drop_table('problem_label')
    # ### end Alembic commands ### 
開發者ID:planbrothers,項目名稱:ml-annotate,代碼行數:29,代碼來源:0fd16cdac8ca_add_multi_label_support.py

示例15: test_arrays

# 需要導入模塊: from sqlalchemy.dialects import postgresql [as 別名]
# 或者: from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION [as 別名]
def test_arrays(metadata):
    Table(
        "simple_items",
        metadata,
        Column("dp_array", postgresql.ARRAY(postgresql.DOUBLE_PRECISION(precision=53))),
        Column("int_array", postgresql.ARRAY(INTEGER)),
    )

    if sqlalchemy.__version__ < "1.1":
        assert (
            generate_code(metadata)
            == """\
# coding: utf-8
from sqlalchemy import Column, Float, Integer, MetaData, Table
from sqlalchemy.dialects.postgresql.base import ARRAY

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('dp_array', ARRAY(Float(precision=53))),
    Column('int_array', ARRAY(Integer()))
)
"""
        )
    else:
        assert (
            generate_code(metadata)
            == """\
# coding: utf-8
from sqlalchemy import ARRAY, Column, Float, Integer, MetaData, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('dp_array', ARRAY(Float(precision=53))),
    Column('int_array', ARRAY(Integer()))
)
"""
        ) 
開發者ID:thomaxxl,項目名稱:safrs,代碼行數:45,代碼來源:test_codegen.py


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