[Sqlalchemy-tickets] Issue #3571: Interval vs INTERVAL and python_type (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
|
From: Adrian K. <iss...@bi...> - 2015-11-01 22:10:58
|
New issue 3571: Interval vs INTERVAL and python_type https://bitbucket.org/zzzeek/sqlalchemy/issues/3571/interval-vs-interval-and-python_type Adrian Klaver: SQLAlchemy 1.0.9 Python 2.7.10 Postgres 9.4.4 Seems the SQL Interval type has two spellings in the code. This seems to be causing an issue when using *.python_type So on Postgres: test=> \d agate_interval_test Table "public.agate_interval_test" Column | Type | Modifiers --------------+----------+----------- id | integer | interval_fld | interval | Using SQLAlchemy: In [23]: from sqlalchemy import Column, MetaData, Table, create_engine In [24]: from sqlalchemy.engine import Connection In [25]: engine = create_engine('postgresql://aklaver:@localhost:5432/test') In [26]: connection = engine.connect() In [27]: metadata = MetaData(connection) In [28]: sql_table = Table('agate_interval_test', metadata, autoload=True, autoload_with=connection) In [31]: for col in sql_table.columns: print col.type ....: INTEGER INTERVAL In [32]: for col in sql_table.columns: print col.type.python_type ....: <type 'int'> --------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) <ipython-input-32-7def2730dfe9> in <module>() 1 for col in sql_table.columns: ----> 2 print col.type.python_type 3 /home/aklaver/py_virt/pandas/lib/python2.7/site-packages/sqlalchemy/sql/type_api.pyc in python_type(self) 305 306 """ --> 307 raise NotImplementedError() 308 309 def with_variant(self, type_, dialect_name): NotImplementedError: In [45]: sqlalchemy.sql.sqltypes.INTERVAL --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-45-fc36ad754ae1> in <module>() ----> 1 sqlalchemy.sql.sqltypes.INTERVAL AttributeError: 'module' object has no attribute 'INTERVAL' In [46]: sqlalchemy.sql.sqltypes.Interval Out[46]: sqlalchemy.sql.sqltypes.Interval |