当我尝试将一行插入到QGIS python插件中包含Null列的sqlite3数据库时,该行永远不会被插入 . 我尝试了不同形式的SQLite 3 Insert命令,但它们都没有插入行 . 我的插件尝试将图层属性表写入Sqlite3上的数据库表 . 插件成功运行,drop然后创建表,但插入过程无法将任何行插入数据库表 .

我可以在QGIS Framework之外成功执行这些相同的插入 . 当涉及NULL列时,在QGIS环境中插入SQLite3数据库时是否需要处理其他内容?

这是我的代码片段:

enter code here

        # insert into database
        for f in selectedLayer.getFeatures():
            line = "','".join(unicode(f[x]) for x in fieldnames) + '\n'
            sqlInsertTable = "INSERT INTO " + self.dlg.txttblname.text() + sqlInsertFieldNames + " VALUES ('" + line.encode('utf-8').strip() + "')"
            sqlInsertTable01 = sqlInsertTable.replace("NULL","null")
            curs.execute(sqlInsertTable01)
            self.dlg.textDebug.append(sqlInsertTable01)