Re: Re: Popularity of Quixote

"m" <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <003401c5da12$3c524be0$6501a8c0@ibmt232>

> PTL is the best new idea from Quixote IMO. I was thinking if it made sense 
> to extend the idea to SQL. For example:
>
> class Accounts:
>     database = 'customer'
>
>     def getAccountName [sql] (account_id):
>         "SELECT name FROM accounts WHERE account_id=%s" % account_id
>
> Calling the method would not only create the SQL string but also execute 
> it and return the query results.
>
> This would enable very clean Python-oriented database access layers.

it would be hideous

ptl outputs plain text, in what form would expect the result set to be in ?

You would also have to escape the output to take into account newlines and 
tabs etc. in the result set.

As an unbounded mass of text, goodbye memory when 500Mb of plain text 
suddenly gets returned.

What about escaping the parameters.
In your example the string is auto wrapped in ' ' and how will the engine 
know when to escape % ?

demonstrated here :

t = 'the amount is 20% over 5 years'

"select a from b where c = '%s' or d like '%%%s%%'" % (t, t)


The Python DB API is already the *perfect* solution (well, almost :)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.