[PyQt] Problem to update with PostgreSQL

Charlie Gentil ceg at redaction-developpez.com
Tue Dec 17 10:37:03 GMT 2013


Hello,

I have a problem with QtSql.
In my code, I want update a table of a PostgreSQL data base. 
In my table I have a column 'dateOut' and it this column is what I want to 
update :


def _update(query, lst):
    model = QtSql.QSqlTableModel()
    model.setQuery(QtSql.QSqlQuery(query))
    model.select()

    record = model.record(0)

    record.setValue('dateOut', lst[2])
    model.setRecord(0, record)

    print(model.lastError().text())
    model.submitAll()


But I have this error :
ERREUR:  erreur de syntaxe sur ou près de « = »
LIGNE 1 : PREPARE qpsqlpstmt_1 AS UPDATE  SET "dateout"=$1 WHERE "id" 
...
                                                       ^
(42601) QPSQL: Unable to prepare statement


Have you an idea ?


Thanks you in advance

Charlie

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20131217/604205bb/attachment.html>


More information about the PyQt mailing list