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


Python sqlalchemy.Float方法代码示例

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


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

示例1: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def upgrade():
    op.add_column('container',
                  sa.Column('cpu', sa.Float(),
                            nullable=True))
    op.add_column('container',
                  sa.Column('workdir', sa.String(length=255),
                            nullable=True))
    op.add_column('container',
                  sa.Column('ports',
                            zun.db.sqlalchemy.models.JSONEncodedList(),
                            nullable=True))
    op.add_column('container',
                  sa.Column('hostname', sa.String(length=255),
                            nullable=True))
    op.add_column('container',
                  sa.Column('labels',
                            zun.db.sqlalchemy.models.JSONEncodedDict(),
                            nullable=True)) 
开发者ID:openstack,项目名称:zun,代码行数:20,代码来源:1192ba19a6e9_add_cpu_workdir_ports_hostname_labels_.py

示例2: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def upgrade():
    op.create_table(
        'capsule',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('capsule_version', sa.String(length=255), nullable=True),
        sa.Column('kind', sa.String(length=36), nullable=True),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('restart_policy', sa.String(length=255), nullable=True),
        sa.Column('host_selector', sa.String(length=255), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(length=36), nullable=False),
        sa.Column('status', sa.String(length=255), nullable=True),
        sa.Column('status_reason', sa.Text(), nullable=True),
        sa.Column('message', models.JSONEncodedDict(), nullable=True),
        sa.Column('spec', models.JSONEncodedDict(), nullable=True),
        sa.Column('cpu', sa.Float(), nullable=True),
        sa.Column('memory', sa.String(length=255), nullable=True),
        sa.Column('meta_name', sa.String(length=255), nullable=True),
        sa.Column('meta_labels', models.JSONEncodedList(), nullable=True),
        sa.Column('containers_uuids', models.JSONEncodedList(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
    ) 
开发者ID:openstack,项目名称:zun,代码行数:26,代码来源:a251f1f61217_create_capsule_table.py

示例3: test_notna_dtype

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def test_notna_dtype(self):
        cols = {'Bool': Series([True, None]),
                'Date': Series([datetime(2012, 5, 1), None]),
                'Int': Series([1, None], dtype='object'),
                'Float': Series([1.1, None])
                }
        df = DataFrame(cols)

        tbl = 'notna_dtype_test'
        df.to_sql(tbl, self.conn)
        returned_df = sql.read_sql_table(tbl, self.conn)  # noqa
        meta = sqlalchemy.schema.MetaData(bind=self.conn)
        meta.reflect()
        if self.flavor == 'mysql':
            my_type = sqltypes.Integer
        else:
            my_type = sqltypes.Boolean

        col_dict = meta.tables[tbl].columns

        assert isinstance(col_dict['Bool'].type, my_type)
        assert isinstance(col_dict['Date'].type, sqltypes.DateTime)
        assert isinstance(col_dict['Int'].type, sqltypes.Integer)
        assert isinstance(col_dict['Float'].type, sqltypes.Float) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:test_sql.py

示例4: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('pin_to_public_id',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('PIN', sa.Integer(), nullable=True),
    sa.Column('public_id', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('feedback',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('rating', sa.Float(), nullable=True),
    sa.Column('additional_information', sa.String(), nullable=True),
    sa.Column('transfer_account_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['transfer_account_id'], ['transfer_account.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ### 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:20,代码来源:902a827bc3e4_.py

示例5: compile

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def compile(self):
        # Json column?
        if self.is_column_json:
            # PostgreSQL always returns text values from it, and for aggregation we usually need numbers :)
            column = cast(self.column, Float)
        else:
            # Simply use
            column = self.column

        # Now, handle the operator, and apply it to the expression
        if self.operator == '$max':
            stmt = func.max(column)
        elif self.operator == '$min':
            stmt = func.min(column)
        elif self.operator == '$avg':
            stmt = func.avg(column)
        elif self.operator == '$sum':
            stmt = func.sum(column)
        else:
            raise InvalidQueryError('Aggregate: unsupported operator "{}"'.format(self.operator))
        return self.labeled_expression(stmt) 
开发者ID:kolypto,项目名称:py-mongosql,代码行数:23,代码来源:aggregate.py

示例6: sa_table

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def sa_table():
    choices = ['a', 'b', 'c']
    meta = sa.MetaData()
    post = sa.Table(
        'test_post', meta,
        sa.Column('id', sa.Integer, nullable=False),
        sa.Column('title', sa.String(200), nullable=False),
        sa.Column('category', sa.String(200), nullable=True),
        sa.Column('body', sa.Text, nullable=False),
        sa.Column('views', sa.Integer, nullable=False),
        sa.Column('average_note', sa.Float, nullable=False),
        # sa.Column('pictures', postgresql.JSON, server_default='{}'),
        sa.Column('published_at', sa.DateTime, nullable=False),
        # sa.Column('tags', postgresql.ARRAY(sa.Integer), server_default='{}'),
        sa.Column('status',
                  sa.Enum(*choices, name="enum_name", native_enum=False),
                  server_default="a", nullable=False),
        sa.Column('visible', sa.Boolean, nullable=False),

        # Indexes #
        sa.PrimaryKeyConstraint('id', name='post_id_pkey'))
    return post 
开发者ID:aio-libs,项目名称:aiohttp_admin,代码行数:24,代码来源:db_fixtures.py

示例7: test_column_adaptation

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [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

示例8: calculateAverageTemperatures

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def calculateAverageTemperatures():
    Base = declarative_base()
    Session = sessionmaker(bind=op.get_bind())

    class Sample(Base):
        __tablename__ = 'sample'
        id = sa.Column(sa.Integer, name="id", primary_key=True)
        moveId = sa.Column(sa.Integer, name="move_id", nullable=False)
        temperature = sa.Column(sa.Float, name='temperature')

    class Move(Base):
        __tablename__ = 'move'
        id = sa.Column(sa.Integer, name="id", primary_key=True)
        temperature_avg = sa.Column(sa.Float, name='temperature_avg')

    session = Session()
    averageTemperatures = dict(session.query(Sample.moveId, func.avg(Sample.temperature)).group_by(Sample.moveId).filter(Sample.temperature > 0).all())

    for move in session.query(Move):
        if move.id in averageTemperatures:
            move.temperature_avg = averageTemperatures[move.id]

    session.commit() 
开发者ID:bwaldvogel,项目名称:openmoves,代码行数:25,代码来源:004.py

示例9: test_existing_column_comment_no_change

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def test_existing_column_comment_no_change(self):
        m1 = MetaData()
        m2 = MetaData()

        Table(
            "some_table",
            m1,
            Column("test", String(10), primary_key=True),
            Column("amount", Float, comment="the amount"),
        )

        Table(
            "some_table",
            m2,
            Column("test", String(10), primary_key=True),
            Column("amount", Float, comment="the amount"),
        )

        diffs = self._fixture(m1, m2)

        eq_(diffs, []) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:23,代码来源:test_autogen_comments.py

示例10: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [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) 
开发者ID:alphagov,项目名称:notifications-api,代码行数:19,代码来源:0110_monthly_billing.py

示例11: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def upgrade():
    op.create_table(
        'domain',
        sa.Column('domain', sa.String(length=255), nullable=False),
        sa.Column('organisation_id', postgresql.UUID(as_uuid=True), nullable=False),
        sa.ForeignKeyConstraint(['organisation_id'], ['organisation.id'], ),
        sa.PrimaryKeyConstraint('domain')
    )
    op.create_index(op.f('ix_domain_domain'), 'domain', ['domain'], unique=True)

    op.add_column('organisation', sa.Column('email_branding_id', postgresql.UUID(as_uuid=True), nullable=True))
    op.create_foreign_key('fk_organisation_email_branding_id', 'organisation', 'email_branding', ['email_branding_id'], ['id'])

    op.add_column('organisation', sa.Column('letter_branding_id', postgresql.UUID(as_uuid=True), nullable=True))
    op.create_foreign_key('fk_organisation_letter_branding_id', 'organisation', 'letter_branding', ['letter_branding_id'], ['id'])

    op.add_column('organisation', sa.Column('agreement_signed', sa.Boolean(), nullable=True))
    op.add_column('organisation', sa.Column('agreement_signed_at', sa.DateTime(), nullable=True))
    op.add_column('organisation', sa.Column('agreement_signed_by_id', postgresql.UUID(as_uuid=True), nullable=True))
    op.add_column('organisation', sa.Column('agreement_signed_version', sa.Float(), nullable=True))
    op.add_column('organisation', sa.Column('crown', sa.Boolean(), nullable=True))
    op.add_column('organisation', sa.Column('organisation_type', sa.String(length=255), nullable=True))
    op.create_foreign_key('fk_organisation_agreement_user_id', 'organisation', 'users', ['agreement_signed_by_id'], ['id']) 
开发者ID:alphagov,项目名称:notifications-api,代码行数:25,代码来源:0278_add_more_stuff_to_orgs.py

示例12: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def upgrade():
    relative_modifier = table('relative_modifier',
            column('id', sa.Integer),
            column('value', sa.Float),
            column('numeric_value', sa.Numeric(precision=8, scale=5)))
    op.add_column('relative_modifier',
            sa.Column('numeric_value', sa.Numeric(precision=8, scale=5)))
    conn = op.get_bind()
    sel = select([relative_modifier.c.id, relative_modifier.c.value])
    results = conn.execute(sel)
    q = Decimal(10) ** -5
    for id_, float_value in results:
        decimal_value = Decimal(float_value).quantize(q)
        up = update(relative_modifier).where(relative_modifier.c.id == id_)\
                .values({'numeric_value': decimal_value})
        conn.execute(up)
    op.drop_column('relative_modifier', 'value')
    op.alter_column('relative_modifier', 'numeric_value', nullable=True,
            new_column_name='value', existing_type=sa.Numeric(precision=8,
                    scale=5)) 
开发者ID:paxswill,项目名称:evesrp,代码行数:22,代码来源:5795c29b2c7a_.py

示例13: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def upgrade():
    op.create_table(
        'inventory',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('resource_provider_id', sa.Integer(), nullable=False),
        sa.Column('resource_class_id', sa.Integer(), nullable=False),
        sa.Column('total', sa.Integer(), nullable=False),
        sa.Column('reserved', sa.Integer(), nullable=False),
        sa.Column('min_unit', sa.Integer(), nullable=False),
        sa.Column('max_unit', sa.Integer(), nullable=False),
        sa.Column('step_size', sa.Integer(), nullable=False),
        sa.Column('allocation_ratio', sa.Float(), nullable=False),
        sa.Column('is_nested', sa.Integer(), nullable=False),
        sa.Column('blob', zun.db.sqlalchemy.models.JSONEncodedList(),
                  nullable=True),
        sa.Index('inventory_resource_provider_id_idx',
                 'resource_provider_id'),
        sa.Index('inventory_resource_provider_resource_class_idx',
                 'resource_provider_id', 'resource_class_id'),
        sa.Index('inventory_resource_class_id_idx',
                 'resource_class_id'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint(
            'resource_provider_id', 'resource_class_id',
            name='uniq_inventory0resource_provider_resource_class'),
    ) 
开发者ID:openstack,项目名称:zun,代码行数:30,代码来源:09f196622a3f_create_inventory_table.py

示例14: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def upgrade():
    op.add_column('compute_node',
                  sa.Column('cpus', sa.Integer(), nullable=False))
    op.add_column('compute_node',
                  sa.Column('cpu_used', sa.Float(), nullable=False)) 
开发者ID:openstack,项目名称:zun,代码行数:7,代码来源:8c3d80e18eb5_add_container_cpus_cpu_used_to_compute_.py

示例15: __init__

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Float [as 别名]
def __init__(self, url):
        self.table = Table(self.__tablename__, MetaData(),
                           Column('name', String(64), primary_key=True),
                           Column('group', String(64)),
                           Column('status', String(16)),
                           Column('script', Text),
                           Column('comments', String(1024)),
                           Column('rate', Float(11)),
                           Column('burst', Float(11)),
                           Column('updatetime', Float(32)),
                           mysql_engine='InnoDB',
                           mysql_charset='utf8'
                           )

        self.url = make_url(url)
        if self.url.database:
            database = self.url.database
            self.url.database = None
            try:
                engine = create_engine(self.url, convert_unicode=True, pool_recycle=3600)
                conn = engine.connect()
                conn.execute("commit")
                conn.execute("CREATE DATABASE %s" % database)
            except sqlalchemy.exc.SQLAlchemyError:
                pass
            self.url.database = database
        self.engine = create_engine(url, convert_unicode=True, pool_recycle=3600)
        self.table.create(self.engine, checkfirst=True) 
开发者ID:binux,项目名称:pyspider,代码行数:30,代码来源:projectdb.py


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