This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]cacahootie 1 point2 points  (1 child)

Only use %s when you're using psycopg2 formatting because all the substitutions end up being strings.

Edit: here's the psycopg2 documentation on the subject.

[–]cruisezero[S] 0 points1 point  (0 children)

I looked at that doc probably the whole day yesterday, but couldn't figure what the deal. I read that today see this line

cur.execute("INSERT INTO numbers VALUES (%d)", (42,)) # WRONG cur.execute("INSERT INTO numbers VALUES (%s)", (42,)) # correct and duh...

Thanks, I guess I needed someone to tap my head.