[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] Problem to update with PostgreSQL
From: Charlie Gentil <ceg () redaction-developpez ! com>
Date: 2013-12-17 10:37:03
Message-ID: 2028812.pp7MNkxt6H () debian
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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
[Attachment #5 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; \
font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Hello,</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; "> </p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">I have a problem with QtSql.</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">In my code, I want update a table of a PostgreSQL data base. </p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">In my table I have a column 'dateOut' and it this column is \
what I want to update :</p> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
"> </p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; "> </p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"><span style=" color:#000000;">def _update(</span><span \
style=" font-family:'Monospace'; color:#000000; background-color:#ffffff;">query</span><span \
style=" color:#000000;">, </span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">lst</span><span style=" color:#000000;">):</span></p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier'; \
color:#000000;"> </span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">model</span><span style=" font-family:'Courier New,courier'; \
color:#000000;"> = </span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">QtSql</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">.</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">QSqlTableModel</span><span style=" font-family:'Courier \
New,courier'; color:#000000;">()</span></p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#000000;"> \
</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">model</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">.</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">setQuery</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">(</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">QtSql</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">.</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">QSqlQuery</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">(</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">query</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">))</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" \
font-family:'Courier New,courier'; color:#000000;"> </span><span style=" \
font-family:'Monospace'; color:#000000; background-color:#ffffff;">model</span><span style=" \
font-family:'Courier New,courier'; color:#000000;">.</span><span style=" \
font-family:'Monospace'; color:#000000; background-color:#ffffff;">select</span><span style=" \
font-family:'Courier New,courier'; color:#000000;">()</span></p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; "> </p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#000000;"> \
</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">record</span><span style=" font-family:'Courier New,courier'; \
color:#000000;"> = </span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">model</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">.</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">record</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">(0)</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
"> </p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier \
New,courier'; color:#000000;"> </span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">record</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">.</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">setValue</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">('dateOut', </span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">lst</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">[2])</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" \
font-family:'Courier New,courier'; color:#000000;"> </span><span style=" \
font-family:'Monospace'; color:#000000; background-color:#ffffff;">model</span><span style=" \
font-family:'Courier New,courier'; color:#000000;">.</span><span style=" \
font-family:'Monospace'; color:#000000; background-color:#ffffff;">setRecord</span><span \
style=" font-family:'Courier New,courier'; color:#000000;">(0, </span><span style=" \
font-family:'Monospace'; color:#000000; background-color:#ffffff;">record</span><span style=" \
font-family:'Courier New,courier'; color:#000000;">)</span></p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; "> </p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#000000;"> \
print(</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">model</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">.</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">lastError</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">().</span><span style=" font-family:'Monospace'; color:#000000; \
background-color:#ffffff;">text</span><span style=" font-family:'Courier New,courier'; \
color:#000000;">())</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" \
font-family:'Courier New,courier'; color:#000000;"> </span><span style=" \
font-family:'Monospace'; color:#000000; background-color:#ffffff;">model</span><span style=" \
font-family:'Courier New,courier'; color:#000000;">.</span><span style=" \
font-family:'Monospace'; color:#000000; background-color:#ffffff;">submitAll</span><span \
style=" font-family:'Courier New,courier'; color:#000000;">()</span></p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; "> </p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; "> </p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#000000;">But I have \
this error :</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">ERREUR: erreur de \
syntaxe sur ou près de « = »</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">LIGNE 1 : PREPARE \
qpsqlpstmt_1 AS UPDATE SET "dateout"=$1 WHERE "id" ...</p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"> \
^</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">(42601) QPSQL: Unable to prepare \
statement</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; "> </p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; "> </p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">Have you an idea ?</p> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
"> </p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; "> </p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">Thanks you in advance</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; "> </p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">Charlie</p> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
"> </p></body></html>
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic