我尝试将我的Django应用程序连接到Oracle DB,但查询结果异常:
TypeError: argument of type 'int' is not iterable异常位置:_rowfactory中的/opt/isep/venv/lib/python3.4/site-packages/django/db/backends/oracle/base.py,第560行
def _rowfactory(row, cursor):
# Cast numeric values as the appropriate Python type based upon the
# cursor description, and convert strings to unicode.
casted = []
for value, desc in zip(row, cursor.description):
if value is not None and desc[1] is Database.NUMBER:
precision = desc[4] or 0
scale = desc[5] or 0
if scale == -127:
if precision == 0:
# NUMBER column: decimal-precision floating point
# This will normally be an integer from a sequence,
# but it could be a decimal value.
if '.' in value:
value = decimal.Decimal(value)
else:
value = int(value)
else:
# FLOAT column: binary-precision floating point.
# This comes from FloatField columns.
value = float(value)
elif precision > 0:
# NUMBER(p,s) column: decimal-precision fixed point.
# This comes from IntField and DecimalField columns.
if scale == 0:
value = int(value)
else:
value = decimal.Decimal(value)
elif '.' in value:
# No type information. This normally comes from a
# mathematical expression in the SELECT list. Guess int
# or Decimal based on whether it has a decimal point.
value = decimal.Decimal(value)
else:
value = int(value)
elif desc[1] in (Database.STRING, Database.FIXED_CHAR,
Database.LONG_STRING):
value = to_unicode(value)
casted.append(value)
return tuple(casted)由于value = 0,if '.' in value:行出现错误。
我使用的是:Python3.4,Django1.11,cx_Oracle 6.0。
我该如何解决这个问题呢?
发布于 2018-09-05 14:10:20
好的,我移除了我的venv,然后创建了另一个venv。这次我安装了Django 1.11.15和cx_Oracle 6.0。一切似乎都运行得很好。异常已消失。
https://stackoverflow.com/questions/52168027
复制相似问题