[PyKDE] QSqlRecord - adding a field (PyQt)

joanne matthews (RRes-Roth) joanne.matthews at bbsrc.ac.uk
Tue Jan 23 13:11:35 GMT 2007


I'm just trying to add a field to a record like this:

db = QtSql.QSqlDatabase.addDatabase("QSQLITE")
db.setDatabaseName("databaseName")
rec=db.record("tableName")
if not rec.contains("fieldName"):
    fieldNotExistError("tableName","fieldName")
    #fieldName=QtSql.QSqlField("exportGIS",QtCore.QVariant.Int)
    fieldName=QtSql.QSqlField()
    fieldName.setName("fieldName")
    fieldName.setType(QtCore.QVariant.Int)
    print db.lastError().text()
    rec.append(fieldName)

But it doesn't append the field. I've also tried rec.insert() but that
doesn't insert the field either. I don't get any error messages printed.
Can someone tell me what I'm doing wrong.

Thanks


    




More information about the PyQt mailing list