1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| def addPal(self,idCoul,pds,no,dateFab,com,conf,idCmd=None):
QSqlDatabase.database().transaction()
query = QSqlQuery()
query.prepare("INSERT INTO bscPal \
(couleurPal,pdsPal,noPal,dateFabPal,comPal,conformePal) \
VALUES (?,?,?,?,?,?)")
query.addBindValue(idCoul)
query.addBindValue(pds)
query.addBindValue(no)
query.addBindValue(dateFab)
query.addBindValue(com)
query.addBindValue(conf)
if not query.exec_():
print(query.lastError().text())
if idCmd:
idPal = query.lastInsertId()
query.prepare("INSERT INTO linkCmdPal \
(idCmdLink,idPalLink) VALUES (?,?)")
query.addBindValue(idCmd)
query.addBindValue(idPal)
if not query.exec_():
print(query.lastError().text())
if QSqlDatabase.database().commit():
print("ok")
return True
else:
print("error")
print(QSqlDatabase.database().lastError().text())
return False |
Partager