I am inserting data into a Postgres DB using Psycopg2 using:
params = "ts, price, volume"
entry = (1234567, None, 3)
cur.execute(f"INSERT INTO stock_data ({params}) VALUES {entry};")
I have used this pattern of f-string with params and a tuple entry countless times with no issue.
For additional information, the price column does not have any constraints and is a numeric(5).
For this particular instance, it is giving me the error:
psycopg2.ProgrammingError: column "none" does not exist
Everything I tried resulted in this error. What did end up working was not using an f-string. The following entry worked:
cur.execute(f"INSERT INTO stock_data ({params}) VALUES (%s, %s, %s);", entry)
My understanding is that these are identical. Why would the latter work, but including the entry directly into the INSERT statement not work?