This question has been flagged
1 Reply
3035 Views


when i execute this sql query,

{ sql2 = 'INSERT INTO gest_caisse (mt_depense, appro_id, name) VALUES ('+str(total)+', '+str(r.id)+', '+str(r.odate)+')'

(and r.odate is a date like 2019-05-14 ...) }

i got this error {


psycopg2.ProgrammingError: ERREUR:  la colonne « name » est de type date mais l'expression est de type integer
LINE 1: ...isse (mt_depense, appro_id, name) VALUES (0.0, 8, 2019-05-23...
HINT: You must rewrite the expression or apply a type transformation to it.

}

so how can i transfor my r.odate to execute my query correctly.


Avatar
Discard
Best Answer

I am not sure what is causing this issue. But I can guide you to find the issue.

Print the value of sql2 variable that has the query. Check the query on the terminal / log file and make sure the syntax and everything is correct.

Also, you can try to run the printed query on postgres.

Avatar
Discard