Python sqlalchemy.dialects.postgresql.DOUBLE_PRECISION Examples
The following are 15
code examples of sqlalchemy.dialects.postgresql.DOUBLE_PRECISION().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy.dialects.postgresql
, or try the search function
.
Example #1
Source File: test_codegen.py From safrs with GNU General Public License v3.0 | 6 votes |
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) ) """ )
Example #2
Source File: test_types.py From sqlalchemy with MIT License | 6 votes |
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")]))
Example #3
Source File: test_types.py From sqlalchemy with MIT License | 6 votes |
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")]))
Example #4
Source File: 96862ec4ff72_.py From SempoBlockchain with GNU General Public License v3.0 | 5 votes |
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 ###
Example #5
Source File: 7036c1830a21_.py From SempoBlockchain with GNU General Public License v3.0 | 5 votes |
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 ###
Example #6
Source File: e3a414cf0342_add_custom_popularity.py From C-3PO with MIT License | 5 votes |
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 ###
Example #7
Source File: compiler.py From ibis with Apache License 2.0 | 5 votes |
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
Example #8
Source File: compiler.py From ibis with Apache License 2.0 | 5 votes |
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
Example #9
Source File: 01e860788b42_change_sigma_to_nullable.py From online-ratings with MIT License | 5 votes |
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 ###
Example #10
Source File: 01e860788b42_change_sigma_to_nullable.py From online-ratings with MIT License | 5 votes |
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 ###
Example #11
Source File: 0114_drop_monthly_billing_cols.py From notifications-api with MIT License | 5 votes |
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 )
Example #12
Source File: 33ef5ceb8902_new_index_for_recentchanges_and_remove_.py From wiki-scripts with GNU General Public License v3.0 | 5 votes |
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 ###
Example #13
Source File: test_types.py From sqlalchemy with MIT License | 5 votes |
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
Example #14
Source File: 0fd16cdac8ca_add_multi_label_support.py From ml-annotate with MIT License | 5 votes |
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 ###
Example #15
Source File: test_codegen.py From safrs with GNU General Public License v3.0 | 4 votes |
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())) ) """ )