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


Python types.Interval方法代碼示例

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


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

示例1: test_python_type

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def test_python_type(self):
        eq_(types.Integer().python_type, int)
        eq_(types.Numeric().python_type, decimal.Decimal)
        eq_(types.Numeric(asdecimal=False).python_type, float)
        eq_(types.LargeBinary().python_type, util.binary_type)
        eq_(types.Float().python_type, float)
        eq_(types.Interval().python_type, datetime.timedelta)
        eq_(types.Date().python_type, datetime.date)
        eq_(types.DateTime().python_type, datetime.datetime)
        eq_(types.String().python_type, str)
        eq_(types.Unicode().python_type, util.text_type)
        eq_(types.Enum("one", "two", "three").python_type, str)

        assert_raises(
            NotImplementedError, lambda: types.TypeEngine().python_type
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:18,代碼來源:test_types.py

示例2: test_querying_table

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def test_querying_table(metadata):
    """
    Create an object for test table.

    """

    # When using pytest-xdist, we don't want concurrent table creations
    # across test processes so we assign a unique name for table based on
    # the current worker id.
    worker_id = os.environ.get('PYTEST_XDIST_WORKER', 'master')
    return Table(
        'test_querying_table_' + worker_id, metadata,
        Column('id', types.Integer, autoincrement=True, primary_key=True),
        Column('serial', types.Integer, Sequence("serial_seq")),
        Column('t_string', types.String(60), onupdate='updated'),
        Column('t_list', types.ARRAY(types.String(60))),
        Column('t_enum', types.Enum(MyEnum)),
        Column('t_int_enum', types.Enum(MyIntEnum)),
        Column('t_datetime', types.DateTime()),
        Column('t_date', types.DateTime()),
        Column('t_interval', types.Interval()),
        Column('uniq_uuid', PG_UUID, nullable=False, unique=True, default=uuid4),
    ) 
開發者ID:CanopyTax,項目名稱:asyncpgsa,代碼行數:25,代碼來源:test_querying.py

示例3: initialize

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def initialize(self, connection):
        super(OracleDialect, self).initialize(connection)
        self.implicit_returning = self.__dict__.get(
            'implicit_returning',
            self.server_version_info > (10, )
        )

        if self._is_oracle_8:
            self.colspecs = self.colspecs.copy()
            self.colspecs.pop(sqltypes.Interval)
            self.use_ansi = False 
開發者ID:jpush,項目名稱:jbox,代碼行數:13,代碼來源:base.py

示例4: _resolve_type

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def _resolve_type(self, t, **kw):
        """
        Resolve types for String, Numeric, Date/Time, etc. columns
        """
        t = self.normalize_name(t)
        if t in ischema_names:
            #print(t,ischema_names[t])
            t = ischema_names[t]
            
            if issubclass(t, sqltypes.String):
                return t(length=kw['length']/2 if kw['chartype']=='UNICODE' else kw['length'],\
                            charset=kw['chartype'])

            elif issubclass(t, sqltypes.Numeric):
                return t(precision=kw['prec'], scale=kw['scale'])

            elif issubclass(t, sqltypes.Time) or issubclass(t, sqltypes.DateTime):
                #Timezone
                tz=kw['fmt'][-1]=='Z'

                #Precision                
                prec = kw['fmt']    
                #For some timestamps and dates, there is no precision, or indicatd in scale
                prec = prec[prec.index('(') + 1: prec.index(')')] if '(' in prec else 0
                prec = kw['scale'] if prec=='F' else int(prec)

                #prec = int(prec[prec.index('(') + 1: prec.index(')')]) if '(' in prec else 0
                return t(precision=prec,timezone=tz)

            elif issubclass(t, sqltypes.Interval):
                return t(day_precision=kw['prec'],second_precision=kw['scale'])

            else:
                return t() # For types like Integer, ByteInt

        return ischema_names[None] 
開發者ID:Teradata,項目名稱:sqlalchemy-teradata,代碼行數:38,代碼來源:dialect.py

示例5: test_interval

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def test_interval(self):
        self._test('interval', sqltypes.Interval) 
開發者ID:cockroachdb,項目名稱:sqlalchemy-cockroachdb,代碼行數:4,代碼來源:test_introspection.py

示例6: test_ad_hoc_types

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def test_ad_hoc_types(self):
        """test storage of bind processors, result processors
        in dialect-wide registry."""

        from sqlalchemy.dialects import mysql, postgresql, sqlite
        from sqlalchemy import types

        eng = engines.testing_engine()
        for args in (
            (types.Integer,),
            (types.String,),
            (types.PickleType,),
            (types.Enum, "a", "b", "c"),
            (sqlite.DATETIME,),
            (postgresql.ENUM, "a", "b", "c"),
            (types.Interval,),
            (postgresql.INTERVAL,),
            (mysql.VARCHAR,),
        ):

            @profile_memory()
            def go():
                type_ = args[0](*args[1:])
                bp = type_._cached_bind_processor(eng.dialect)
                rp = type_._cached_result_processor(eng.dialect, 0)
                bp, rp  # strong reference

            go()

        assert not eng.dialect._type_memos 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:32,代碼來源:test_memusage.py

示例7: test_interval_coercion

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def test_interval_coercion(self):
        expr = column("bar", postgresql.INTERVAL) + column("foo", types.Date)
        eq_(expr.type._type_affinity, types.DateTime)

        expr = column("bar", postgresql.INTERVAL) * column(
            "foo", types.Numeric
        )
        eq_(expr.type._type_affinity, types.Interval)
        assert isinstance(expr.type, postgresql.INTERVAL) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:11,代碼來源:test_types.py

示例8: test_date_coercion

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def test_date_coercion(self):
        expr = column("bar", types.NULLTYPE) - column("foo", types.TIMESTAMP)
        eq_(expr.type._type_affinity, types.NullType)

        expr = func.sysdate() - column("foo", types.TIMESTAMP)
        eq_(expr.type._type_affinity, types.Interval)

        expr = func.current_date() - column("foo", types.TIMESTAMP)
        eq_(expr.type._type_affinity, types.Interval) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:11,代碼來源:test_types.py

示例9: test_interval_coercion

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def test_interval_coercion(self):
        expr = column("bar", types.Interval) + column("foo", types.Date)
        eq_(expr.type._type_affinity, types.DateTime)

        expr = column("bar", types.Interval) * column("foo", types.Numeric)
        eq_(expr.type._type_affinity, types.Interval) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:8,代碼來源:test_types.py

示例10: test_non_native_adapt

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def test_non_native_adapt(self):
        interval = Interval(native=False)
        adapted = interval.dialect_impl(testing.db.dialect)
        assert isinstance(adapted, Interval)
        assert adapted.native is False
        eq_(str(adapted), "DATETIME") 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:8,代碼來源:test_types.py

示例11: __init__

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def __init__(self):
        self._types = {
            # Django internal type => SQLAlchemy type
            'ArrayField': SA_ARRAY,
            'AutoField': sa_types.Integer,
            'BigAutoField': sa_types.BigInteger,
            'BigIntegerField': sa_types.BigInteger,
            'BooleanField': sa_types.Boolean,
            'CharField': sa_types.String,
            'DateField': sa_types.Date,
            'DateTimeField': sa_types.DateTime,
            'DecimalField': sa_types.Numeric,
            'DurationField': sa_types.Interval,
            'FileField': sa_types.String,
            'FilePathField': sa_types.String,
            'FloatField': sa_types.Float,
            'GenericIPAddressField': sa_types.String,
            'IntegerField': sa_types.Integer,
            'JSONField': SA_JSONB,
            'NullBooleanField': sa_types.Boolean,
            'PointField': Geometry,
            'PositiveIntegerField': sa_types.Integer,
            'PositiveSmallIntegerField': sa_types.SmallInteger,
            'SlugField': sa_types.String,
            'SmallIntegerField': sa_types.SmallInteger,
            'TextField': sa_types.Text,
            'TimeField': sa_types.Time,
            'UUIDField': SA_UUID,
            # TODO: Add missing GIS fields
        } 
開發者ID:dvhb,項目名稱:dvhb-hybrid,代碼行數:32,代碼來源:convert.py

示例12: initialize

# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import Interval [as 別名]
def initialize(self, connection):
        super(OracleDialect, self).initialize(connection)
        self.implicit_returning = self.__dict__.get(
                                    'implicit_returning',
                                    self.server_version_info > (10, )
                                    )

        if self._is_oracle_8:
            self.colspecs = self.colspecs.copy()
            self.colspecs.pop(sqltypes.Interval)
            self.use_ansi = False 
開發者ID:binhex,項目名稱:moviegrabber,代碼行數:13,代碼來源:base.py


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