[DB-SIG] paramstyles (mysql string length?)

Chris Clark Chris.Clark at ingres.com
Mon Apr 24 23:56:46 CEST 2006

In reference to finding question marks in SQL queries and ignoring 
string literals

M.-A. Lemburg wrote:
> Does anyone know a good implementation of such a search&replace
> mechanism ?
I've not seen any existing code to deal with this BUT there are a couple 
of places to check:

    * SnakeSQL <http://www.pythonweb.org/projects/snakesql/>
    * gadfly <http://gadfly.sourceforge.net/>

as they are pure Python database engines and so have some SQL parsing 
code in them already that maybe usable.

But you can always cheat and iterate through the SQL string and just 
count (incrementing and decrementing) single quotes.
You need to remember to deal with the special case of embedded single 
quotes (by keeping a mini back buffer) like this:

    'it''s Monty Python'


More information about the DB-SIG mailing list