本文整理汇总了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)
)
"""
)
示例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")]))
示例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")]))
示例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 ###
示例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 ###
示例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 ###
示例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
示例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
示例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 ###
示例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 ###
示例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
)
示例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
示例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 ###
示例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()))
)
"""
)