Hi,
When I use an integer as variable in my SQL query it works as it should. However if work with a string It does not work, I don't get an error message but also not results.
THis is the code that works (with variable as integer)
If I change the variable to a string and change my query to %%S instead of %, I don't get an error message but also no results
![[Image: bvkppsksrfavz.22.18.png]](https://www.mupload.nl/img/bvkppsksrfavz.22.18.png)
any tips on what I do wrong?
When I use an integer as variable in my SQL query it works as it should. However if work with a string It does not work, I don't get an error message but also not results.
THis is the code that works (with variable as integer)
1 2 3 4 5 6 7 8 |
import psycopg2 as p conn = p.connect ( "dbname='participants_db' user='postgres' host= 'localhost'" ) cur = conn.cursor() x = 5 cur.execute( "UPDATE participants SET participant_paid = 'Yes' WHERE participant_id = '%s'" , [x]) conn.commit() |
1 2 |
x = ( 'Cleavon' ) cur.execute( "UPDATE participants SET participant_paid = 'Yes' WHERE participant_name = '%%s'" , [x]) |
![[Image: bvkppsksrfavz.22.18.png]](https://www.mupload.nl/img/bvkppsksrfavz.22.18.png)
any tips on what I do wrong?