MySqlDb is a fantastic Python module — but one part is incredibly annoying.
Query parameters look like this
cursor.execute("select * from Books where isbn=%s", (isbn,))
whereas everywhere else in the known universe (oracle, sqlserver, access, sybase…)
they look like this
cursor.execute("select * from Books where isbn=?", (isbn,))
This means that if you want to be portable you have to somehow switch
between the two notations ? and %s,
which is really annoying. (Please don’t tell me to use an
ORM layer — I will strangle you).
Supposedly you can convince mysqldb to use the standard syntax, but I haven’t yet
made it work. Any suggestions?
I found a lot of information out there about
paramstylethat seemed to imply it might be what you wanted, but according to this wiki you have to use theparamstyleyour library uses, and most of them do not allow you to change it:I found some posts that talked about MySQLdb allowing this, but apparently it doesn’t as someone indicated it didn’t work for them.