python - SQLAlchemy returns an integer -
i accessing database using sqlalchemy. when try filter table using bunch of public , private keys attribute error saying 'int' object has no attribute 'date'.
sometimes, able filter results once , when filter called again, crashes giving me same error. problem of sqlalchemy or pydev?
below snippet of filter.
randomize_query(session('test').query(tablename).filter(tablename.field1 == criteria, tablename.field2 == 2).order_by(desc(tablename.field3))).first()
the full traceback below
file "c:\python27\lib\site-packages\sqlalchemy\orm\query.py", line 2145, in first ret = list(self[0:1]) file "c:\python27\lib\site-packages\sqlalchemy\orm\query.py", line 2012, in __getitem__ return list(res) file "c:\python27\lib\site-packages\sqlalchemy\orm\loading.py", line 72, in instances rows = [process[0](row, none) row in fetch] file "c:\python27\lib\site-packages\sqlalchemy\orm\loading.py", line 447, in _instance populate_state(state, dict_, row, isnew, only_load_props) file "c:\python27\lib\site-packages\sqlalchemy\orm\loading.py", line 301, in populate_state populator(state, dict_, row) file "c:\python27\lib\site-packages\sqlalchemy\orm\strategies.py", line 150, in fetch_col dict_[key] = row[col] file "c:\python27\lib\site-packages\sqlalchemy\engine\result.py", line 89, in __getitem__ return processor(self._row[index]) file "c:\python27\lib\site-packages\sqlalchemy\dialects\oracle\cx_oracle.py", line 250, in process return value.date() attributeerror: 'int' object has no attribute 'date'
the exception thrown when result set loaded , sqlalchemy wants populate result objects. 1 column qualified date
type, oracle result set giving integer instead.
the cx_oracle
library convert oracle-supplied native date column value python datetime.datetime
object. however, not happening all rows here.
you'll need narrow down row or rows have column not being translated datetime
object. find pattern in filters include or exclude these rows , narrow down can inspect database rows hand in different client.
Comments
Post a Comment