[DB-SIG] Escaping Placeholders

Denis S. Otkidach ods at strana.ru
Wed Jul 7 14:28:17 CEST 2004


On Tue, 6 Jul 2004, Peter L. Buschman wrote:

PLB> Thanks.  Are you saying there is no explicit escaping of
PLB> placeholders?  If
PLB> so, that actually makes my problem
PLB> somewhat easier as I am working on a set of translation
PLB> routines to convert
PLB> from any paramstyle to any other

Is it possible?  In fact you need a SQL parser for each RDBMS, so
coverters will be database dependent.  The other way is to have
one "good" style to define queries, that can be easily converted
to any paramstyle, e.g. look at this one:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278612
http://cvs.sourceforge.net/viewcvs.py/ppa/misc/DBSingleStyle.py?rev=HEAD&content-type=text/vnd.viewcvs-markup

This approach is used in some production projects with several
different databases, but I cannot guaranty it works for every
RDBMS.

PLB> paramstyle.  Going from ?,?,? to :1,:2:,:3,
PLB> :param1,:param2,:param3,
PLB> %s,%s,%s, or :%(param1)s,%(param2)s,%(param3)s
PLB> is actually quite easy if you don't need to deal with
PLB> escaped parameters
PLB> that screw up your search and replace
PLB> routines.

Anyway, using list of raw chunks and parameters will work faster
than parsing and constructing query.

-- 
Denis S. Otkidach
http://www.python.ru/      [ru]


More information about the DB-SIG mailing list