我正在为 python 日志记录模块开发一个处理程序。这基本上记录到一个 oracle 数据库。
我正在使用 cx_oracle,我不知道如何获取表为空时的列值。
cursor.execute('select * from FOO')
for row in cursor:
# this is never executed because cursor has no rows
print '%s\n' % row.description
# This prints none
row = cursor.fetchone()
print str(row)
row = cursor.fetchvars
# prints useful info
for each in row:
print each
输出是:
None
<cx_Oracle.DATETIME with value [None, None, None, None, None, None, None, None, None, None, None, None, None, None, None
, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None
, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]>
<cx_Oracle.STRING with value [None, None, None, None, None, None, None, None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]>
现在查看 var 数据,我可以看到数据类型及其大小(计数无?),但缺少列名。
我该怎么办?