This is not that relevant so I'm just curious about the following (Python 2.7):
I just began using psycopg and reading through the docs they always use strings (%s) and tuples for passing values to a query.
The variables placeholder must always be a %s
So considering the following example-
In a table named 'test' with the fields value_1 (varchar) and value_2 (int) a query is created as:
value_1 = "test"
value_2 = "100"
cur.execute("INSERT INTO test (value_1,value_2) VALUES (%s,%s)",\
(value_1,value_2))
My question is if it's a bad practice or even problematic to use the 'format' method instead (as follows):
cur.execute("INSERT INTO test (value_1,value_2) VALUES ('{value1}',{value2})".\
format(value1=value_1,value2=value_2))
What do you say based on your experience, is it really dangerous or problematic?