I use the DBAPI's pyformat query format exclusively. It's supported by both the PostgreSQL and MySQL drivers, and it's just a superior mechanism for creating queries (especially with PyTable's SQLQuery class). So, of course, as I was writing the SQLite driver for PyTable I was obviously using pyformat queries.
Problem was, SQLite doesn't support them, so every time I would parameterise my query SQLite would start spitting out those opaque syntax error messages. Eventually I realised what was going on, and gave up in disgust to take a nap.
Woke up about 3 hours later with the solution. A class that allows for using pyformat queries even on databases that only support qmark, numeric, named or format paramstyles.
The class (that link should become live once ViewCVS catches up) seems to work very nicely with SQLite in my minimal tests so far.
Since everything I write uses SQLQuery, I can actually introduce this at the SQLQuery level and have the conversion happen automatically based on whether the (connection's) driver has the queryPyformat capability. It's a performance hit for those drivers that don't support pyformat, but PyTable is about reducing coding time, not about to-the-metal speed.
Rather neat hack IMO.
Pingbacks are closed.