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


Python types.Integer方法代码示例

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


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

示例1: get_type

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def get_type(data_type):
    type_map = {
        "bytes": types.LargeBinary,
        "boolean": types.Boolean,
        "date": types.Date,
        "datetime": types.DateTime,
        "double": types.Numeric,
        "text": types.String,
        "keyword": types.String,
        "integer": types.Integer,
        "half_float": types.Float,
        "geo_point": types.String,
        # TODO get a solution for nested type
        "nested": types.String,
        # TODO get a solution for object
        "object": types.BLOB,
        "long": types.BigInteger,
        "float": types.Float,
        "ip": types.String,
    }
    type_ = type_map.get(data_type)
    if not type_:
        logger.warning(f"Unknown type found {data_type} reverting to string")
        type_ = types.String
    return type_ 
开发者ID:preset-io,项目名称:elasticsearch-dbapi,代码行数:27,代码来源:basesqlalchemy.py

示例2: fields_map

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def fields_map(self, field_type):
        if field_type == "primary":
            return ID(stored=True, unique=True)
        type_map = {
            'date': types.Date,
            'datetime': types.DateTime,
            'boolean': types.Boolean,
            'integer': types.Integer,
            'float': types.Float
        }
        if isinstance(field_type, str):
            field_type = type_map.get(field_type, types.Text)

        if not isinstance(field_type, type):
            field_type = field_type.__class__

        if issubclass(field_type, (types.DateTime, types.Date)):
            return DATETIME(stored=True, sortable=True)
        elif issubclass(field_type, types.Integer):
            return NUMERIC(stored=True, numtype=int)
        elif issubclass(field_type, types.Float):
            return NUMERIC(stored=True, numtype=float)
        elif issubclass(field_type, types.Boolean):
            return BOOLEAN(stored=True)
        return TEXT(stored=True, analyzer=self.analyzer, sortable=False) 
开发者ID:honmaple,项目名称:flask-msearch,代码行数:27,代码来源:whoosh_backend.py

示例3: _add_annotation_docs_to_sqlite

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def _add_annotation_docs_to_sqlite(dbcon, annotation_docs, item):
    # add full item path for convenience
    annotation_docs.loc[:, "item_name"] = item['name']

    # save tables to sqlite
    annotation_docs.to_sql(
        name='annotation_docs', con=dbcon, if_exists='append',
        dtype={
            'annotation_girder_id': String(),
            '_modelType': String(),
            '_version': Integer(),
            'itemId': String(),
            'item_name': String(),
            'created': String(),
            'creatorId': String(),
            'public': Boolean(),
            'updated': String(),
            'updatedId': String(),
            'groups': String(),
            'element_count': Integer(),
            'element_details': Integer(), },
        index=False,
    ) 
开发者ID:DigitalSlideArchive,项目名称:HistomicsTK,代码行数:25,代码来源:annotation_database_parser.py

示例4: _add_annotation_elements_to_sqlite

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def _add_annotation_elements_to_sqlite(dbcon, annotation_elements):
    # drop index relative to JSON since its pretty arbitrary and would
    # change if the same girder client was used to get annotations twice
    # the actual girder ID string is what really matters and should be used
    annotation_elements.drop(
        labels=['annidx', 'elementidx'], axis=1, inplace=True)

    annotation_elements.to_sql(
        name='annotation_elements', con=dbcon, if_exists='append',
        dtype={
            'annotation_girder_id': String(),
            'element_girder_id': String(),
            'type': String(),
            'group': String(),
            'label': String(),
            'color': String(),
            'xmin': Integer(),
            'xmax': Integer(),
            'ymin': Integer(),
            'ymax': Integer(),
            'bbox_area': Integer(),
            'coords_x': String(),
            'coords_y': String(), },
        index=False,
    ) 
开发者ID:DigitalSlideArchive,项目名称:HistomicsTK,代码行数:27,代码来源:annotation_database_parser.py

示例5: set_quality

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def set_quality(stage):
    ''' produces cube quality flag '''

    col = 'DRP2QUAL' if stage == '2d' else 'DRP3QUAL'
    label = 'cubequal{0}'.format(stage)
    kwarg = 'DRP{0}QUAL'.format(stage[0])

    @hybrid_property
    def quality(self):
        bits = self.getQualBits(stage=stage)
        return int(bits)

    @quality.expression
    def quality(cls):
        return select([FitsHeaderValue.value.cast(Integer)]).\
                      where(and_(FitsHeaderKeyword.pk==FitsHeaderValue.fits_header_keyword_pk,
                                 FitsHeaderKeyword.label.ilike(kwarg),
                                 FitsHeaderValue.cube_pk==cls.pk)).\
                      label(label)
    return quality 
开发者ID:sdss,项目名称:marvin,代码行数:22,代码来源:DataModelClasses.py

示例6: set_manga_target

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def set_manga_target(targtype):
    ''' produces manga_target flags '''

    label = 'mngtrg{0}'.format(targtype)
    kwarg = 'MNGT%RG{0}'.format(targtype)

    @hybrid_property
    def target(self):
        bits = self.getTargBits(targtype=targtype)
        return int(bits)

    @target.expression
    def target(cls):
        return select([FitsHeaderValue.value.cast(Integer)]).\
                      where(and_(FitsHeaderKeyword.pk==FitsHeaderValue.fits_header_keyword_pk,
                                 FitsHeaderKeyword.label.ilike(kwarg),
                                 FitsHeaderValue.cube_pk==cls.pk)).\
                      label(label)
    return target 
开发者ID:sdss,项目名称:marvin,代码行数:21,代码来源:DataModelClasses.py

示例7: spaxel_factory

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def spaxel_factory(classname, clean=None):
    ''' class factory for the spaxelprop tables '''

    if clean:
        classname = 'Clean{0}'.format(classname)
    tablename = classname.lower()

    params = {'__tablename__': tablename, '__table_args__': {'autoload': True, 'schema': 'mangadapdb'}}
    if clean:
        params.update({'pk': Column(Integer, primary_key=True)})

    def newrepr(self):
        return '<{2} (pk={0}, file={1})'.format(self.pk, self.file_pk, classname)

    try:
        newclass = type(classname, (Base, SpaxelAtts,), params)
        newclass.__repr__ = newrepr
    except Exception as e:
        newclass = None

    return newclass


# create the (clean)spaxel models from the DAP datamodel 
开发者ID:sdss,项目名称:marvin,代码行数:26,代码来源:DapModelClasses.py

示例8: visit_column

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def visit_column(self, delta):
        table = delta.table
        colspec = self.get_column_specification(delta.result_column)
        if delta.result_column.autoincrement:
            primary_keys = [c for c in table.primary_key.columns
                       if (c.autoincrement and
                            isinstance(c.type, sqltypes.Integer) and
                            not c.foreign_keys)]

            if primary_keys:
                first = primary_keys.pop(0)
                if first.name == delta.current_name:
                    colspec += " AUTO_INCREMENT"
        q = util.safe_quote(table)
        old_col_name = self.preparer.quote(delta.current_name, q)

        self.start_alter_table(table)

        self.append("CHANGE COLUMN %s " % old_col_name)
        self.append(colspec)
        self.execute() 
开发者ID:gltn,项目名称:stdm,代码行数:23,代码来源:mysql.py

示例9: _adapt_expression

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def _adapt_expression(self, op, other_comparator):
            """evaluate the return type of <self> <op> <othertype>,
            and apply any adaptations to the given operator.

            This method determines the type of a resulting binary expression
            given two source types and an operator.   For example, two
            :class:`.Column` objects, both of the type :class:`.Integer`, will
            produce a :class:`.BinaryExpression` that also has the type
            :class:`.Integer` when compared via the addition (``+``) operator.
            However, using the addition operator with an :class:`.Integer`
            and a :class:`.Date` object will produce a :class:`.Date`, assuming
            "days delta" behavior by the database (in reality, most databases
            other than Postgresql don't accept this particular operation).

            The method returns a tuple of the form <operator>, <type>.
            The resulting operator and type will be those applied to the
            resulting :class:`.BinaryExpression` as the final operator and the
            right-hand side of the expression.

            Note that only a subset of operators make usage of
            :meth:`._adapt_expression`,
            including math operators and user-defined operators, but not
            boolean comparison or special SQL keywords like MATCH or BETWEEN.

            """
            return op, other_comparator.type 
开发者ID:jpush,项目名称:jbox,代码行数:28,代码来源:type_api.py

示例10: define_tables

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def define_tables(cls, metadata):
        Table('test_table', metadata,
              Column('id', Integer, primary_key=True),
              Column('data', String(50))
              ) 
开发者ID:jpush,项目名称:jbox,代码行数:7,代码来源:test_reflection.py

示例11: test_nullable_reflection

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def test_nullable_reflection(self):
        t = Table('t', self.metadata,
                  Column('a', Integer, nullable=True),
                  Column('b', Integer, nullable=False))
        t.create()
        eq_(
            dict(
                (col['name'], col['nullable'])
                for col in inspect(self.metadata.bind).get_columns('t')
            ),
            {"a": True, "b": False}
        ) 
开发者ID:jpush,项目名称:jbox,代码行数:14,代码来源:test_reflection.py

示例12: check_constraint

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def check_constraint(self, name, source, condition, schema=None, **kw):
        t = sa_schema.Table(source, self.metadata(),
                            sa_schema.Column('x', Integer), schema=schema)
        ck = sa_schema.CheckConstraint(condition, name=name, **kw)
        t.append_constraint(ck)
        return ck 
开发者ID:jpush,项目名称:jbox,代码行数:8,代码来源:schemaobj.py

示例13: compare_server_default

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def compare_server_default(self, inspector_column,
                               metadata_column,
                               rendered_metadata_default,
                               rendered_inspector_default):
        # partially a workaround for SQLAlchemy issue #3023; if the
        # column were created without "NOT NULL", MySQL may have added
        # an implicit default of '0' which we need to skip
        if metadata_column.type._type_affinity is sqltypes.Integer and \
            inspector_column.primary_key and \
                not inspector_column.autoincrement and \
                not rendered_metadata_default and \
                rendered_inspector_default == "'0'":
            return False
        else:
            return rendered_inspector_default != rendered_metadata_default 
开发者ID:jpush,项目名称:jbox,代码行数:17,代码来源:mysql.py

示例14: get_columns

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def get_columns(self, connection, table_name, schema=None, **kw):
        # Extend types supported by PrestoDialect as defined in PyHive
        type_map = {
            'bigint': sql_types.BigInteger,
            'integer': sql_types.Integer,
            'boolean': sql_types.Boolean,
            'double': sql_types.Float,
            'varchar': sql_types.String,
            'timestamp': sql_types.TIMESTAMP,
            'date': sql_types.DATE,
            'array<bigint>': sql_types.ARRAY(sql_types.Integer),
            'array<varchar>': sql_types.ARRAY(sql_types.String)
        }

        rows = self._get_table_columns(connection, table_name, schema)
        result = []
        for row in rows:
            try:
                coltype = type_map[row.Type]
            except KeyError:
                logger.warn("Did not recognize type '%s' of column '%s'" % (row.Type, row.Column))
                coltype = sql_types.NullType
            result.append({
                'name': row.Column,
                'type': coltype,
                # newer Presto no longer includes this column
                'nullable': getattr(row, 'Null', True),
                'default': None,
            })
        return result 
开发者ID:airbnb,项目名称:omniduct,代码行数:32,代码来源:_schemas.py

示例15: test_reflect_select

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import Integer [as 别名]
def test_reflect_select(table, table_using_test_dataset):
    for table in [table, table_using_test_dataset]:
        assert len(table.c) == 18

        assert isinstance(table.c.integer, Column)
        assert isinstance(table.c.integer.type, types.Integer)
        assert isinstance(table.c.timestamp.type, types.TIMESTAMP)
        assert isinstance(table.c.string.type, types.String)
        assert isinstance(table.c.float.type, types.Float)
        assert isinstance(table.c.boolean.type, types.Boolean)
        assert isinstance(table.c.date.type, types.DATE)
        assert isinstance(table.c.datetime.type, types.DATETIME)
        assert isinstance(table.c.time.type, types.TIME)
        assert isinstance(table.c.bytes.type, types.BINARY)
        assert isinstance(table.c['record.age'].type, types.Integer)
        assert isinstance(table.c['record.name'].type, types.String)
        assert isinstance(table.c['nested_record.record.age'].type, types.Integer)
        assert isinstance(table.c['nested_record.record.name'].type, types.String)
        assert isinstance(table.c.array.type, types.ARRAY)

        rows = table.select().execute().fetchall()
        assert len(rows) == 1000 
开发者ID:mxmzdlv,项目名称:pybigquery,代码行数:24,代码来源:test_sqlalchemy_bigquery.py


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