sql - How do you make the Python Msqldb module use ? in stead of %s for query parameters? -
MySqlDb is a great Python module - but one part is incredibly annoying. Query parameters look like this
cursor.secute ("select from books where isbn =% s", (isbn,)) while They look like this everywhere in the known universe (oracle, sqlserver, access, sybase ...)
cursor Execute ("Select from books where isbn =?", (Isbn,)) This means that if you want to be portable, Need to switch? And% s, which is really upset (please do not tell me to use an ORM layer - I'll hug you).
It is believed that you can understand mysqldb to use standard syntax, but I have not worked on it yet. any suggestion?
I get a lot of information paramstyle It may be that what you wanted, but you have to use the paramstyle to use your library, and most of them do not allow you to change it:
paramstyleis specific to the library and information you use - using the one you use it Maybe it's the most annoying part of the standard. (Some allow you to set differentparamstyles, but this is not standard behavior)
I have received some posts that I talked about MySQLdb , But apparently no one has indicated that this does not work for them.
Comments
Post a Comment