sqlstring -- a library to build a SELECT statement

Tom Anderson twic at urchin.earth.li
Thu Oct 20 23:21:21 CEST 2005


On Thu, 20 Oct 2005, Pierre Quentel wrote:

> grunar at gmail.com a écrit :
>
>> My solution is sqlstring. A single-purpose library: to create SQL
>> statement objects.
>
> With the same starting point - I don't like writing SQL strings inside Python 
> code either - I have tested a different approach : use the Python list 
> comprehension / generator expression syntax for the select requests
>
> For instance :
>
> s = query(r.name for r in planes if r.speed > 500)
> for item in s:
> 	print s
>
> query is a class whose instances are created with the generator 
> expression as argument. The matching SQL request is built in the 
> __init__ method, here :
>
> SELECT r.name FROM planes AS r WHERE r.speed > 500

That, sir, is absolute genius.

Evil as fuck, but still absolute genius.

tom

-- 
NOW ALL ASS-KICKING UNTIL THE END


More information about the Python-list mailing list