将python中的无值插入firebird表中

时间:2015-04-04 16:44:35

标签: python firebird

我试图将包含None值的python变量插入到firebird表中,但它会引发错误(当我插入一个随机值时,它工作正常):

fdb.fbcore.DatabaseError: ('Error while executing SQL statement:\n- SQLCODE: -802\n- arithmetic exception, numeric overf
low, or string truncation\n- string right truncation', -802, 335544321)

python代码如下:

import fdb

con = fdb.connect(dsn='OFFICINE.gdb', user='SYSDBA', password='masterkey')
cur = con.cursor()

spec = None

cur.execute("update ENTETEFACT set SPECIALITE = '%s' where N_FACTURE = '04139412' " %spec)
con.commit()

1 个答案:

答案 0 :(得分:0)

为什么要尝试字符串格式而不是传递参数?

cur.execute("update ENTETEFACT set SPECIALITE = %s where N_FACTURE = '04139412' ", [spec])