Python sqlalchemy.types.Interval() Examples
The following are 18
code examples of sqlalchemy.types.Interval().
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.types
, or try the search function
.
Example #1
Source File: test_querying.py From asyncpgsa with Apache License 2.0 | 6 votes |
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), )
Example #2
Source File: test_types.py From sqlalchemy with MIT License | 6 votes |
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")
Example #3
Source File: test_types.py From sqlalchemy with MIT License | 6 votes |
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)
Example #4
Source File: test_types.py From sqlalchemy with MIT License | 6 votes |
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)
Example #5
Source File: test_types.py From sqlalchemy with MIT License | 5 votes |
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 )
Example #6
Source File: base.py From android_universal with MIT License | 5 votes |
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
Example #7
Source File: base.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
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
Example #8
Source File: convert.py From dvhb-hybrid with MIT License | 5 votes |
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 }
Example #9
Source File: base.py From jarvis with GNU General Public License v2.0 | 5 votes |
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
Example #10
Source File: base.py From jbox with MIT License | 5 votes |
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
Example #11
Source File: test_types.py From sqlalchemy with MIT License | 5 votes |
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)
Example #12
Source File: test_memusage.py From sqlalchemy with MIT License | 5 votes |
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
Example #13
Source File: test_introspection.py From sqlalchemy-cockroachdb with Apache License 2.0 | 5 votes |
def test_interval(self): self._test('interval', sqltypes.Interval)
Example #14
Source File: base.py From stdm with GNU General Public License v2.0 | 5 votes |
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
Example #15
Source File: base.py From pyRevit with GNU General Public License v3.0 | 5 votes |
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
Example #16
Source File: base.py From planespotter with MIT License | 5 votes |
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
Example #17
Source File: dialect.py From sqlalchemy-teradata with MIT License | 5 votes |
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]
Example #18
Source File: base.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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