我使用python 2.7 64 Bit从Oracle数据库中提取数据。有一个35位数字类型的字段:1200000000000000000000000000005151
如果我想用SQL Alchemy读取这个字段,我会收到以下错误:
File "D:\Produkte\CoCo\Sourcen\ConsultingConnector\src\ais.py", line 253, in tabledata2table
for row in tabledata.yield_per(buffersize).enable_eagerloads(False):
File "C:\Python27\lib\site-packages\sqlalchemy\orm\loading.py", line 98, in instances
util.raise_from_cause(err)
File "C:\Python27\lib\site-packages\sqlalchemy\util\compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "C:\Python27\lib\site-packages\sqlalchemy\orm\loading.py", line 71, in instances
fetch = cursor.fetchmany(query._yield_per)
File "C:\Python27\lib\site-packages\sqlalchemy\engine\result.py", line 1166, in fetchmany
self.cursor, self.context)
File "C:\Python27\lib\site-packages\sqlalchemy\engine\base.py", line 1413, in _handle_dbapi_exception
exc_info
File "C:\Python27\lib\site-packages\sqlalchemy\util\compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "C:\Python27\lib\site-packages\sqlalchemy\engine\result.py", line 1159, in fetchmany
l = self.process_rows(self._fetchmany_impl(size))
File "C:\Python27\lib\site-packages\sqlalchemy\engine\result.py", line 1076, in _fetchmany_impl
return self.cursor.fetchmany(size)
sqlalchemy.exc.DatabaseError: (cx_Oracle.DatabaseError) ORA-01455: converting column overflows integer datatype (Background on this error at: http://sqlalche.me/e/4xp6)
似乎SQL Alchemy试图使用int进行转换,即使它很长。 您是否知道如何解决问题或解决方法?
提前致谢, Jassin
答案 0 :(得分:0)
我遇到了同样的问题,并提出了将数据类型转换为字符的解决方案。例如“选择to_char(ID)”。