[ANN] istring 1.0.1 released; announce list created

Andy Gimblett gimbo at ftech.net
Wed Mar 6 10:12:23 EST 2002


On Wed, Mar 06, 2002 at 08:58:51AM -0600, Skip Montanaro wrote:
> 
>     Duncan> I vote for (3):
>     Duncan>   db.query("""SELECT    foo, bar
>     Duncan>               FROM      %(table)s
>     Duncan>               WHERE     rsrc_id = %(rsrc_id)s
>     Duncan>               AND       name = '%(name)s'" % vars())
> 
> Which will work most of the time, but fail if name contains any apostrophes.
> As was mentioned before, that's why the DB API supports a query method that
> does its own variable interpolation.  Different databases quote things in
> different ways.

We seem to be getting mixed up over two seperate issues here, which we
should try to keep seperate:

1. Whether $table style string interpolation is a desirable or
   necessary addition to python.

2. How to do variable interpolation in SQL strings.

For my money, issue 2 is addressed as above by Skip (ie let the DB API
sort it out), and the question mark over 1 is: why is $table style
necessary when we've got %(table) style?

-Andy

-- 
Andy Gimblett - Programmer - Frontier Internet Services Limited
Tel: 029 20 820 044 Fax: 029 20 820 035 http://www.frontier.net.uk/
Statements made are at all times subject to Frontier's Terms and
Conditions of Business, which are available upon request.




More information about the Python-list mailing list