List/Tuple bug or feature?
aleax at aleax.it
Thu Sep 26 16:00:50 CEST 2002
Dennis Lee Bieber wrote:
> sismex01 at hebmex.com fed this fish to the penguins on Tuesday 24
> September 2002 03:12 pm:
>> It's one of python's features :-)
>> For when you wanna write a long string, SQL for example:
>> Query = "SELECT what, when, where, why "
>> "FROM t1, t2, t2 "
>> "WHERE t1.id = t2.id_t1 and t3.id_t2 = t2.id and t1.id_t2 =
>> t3.id " "AND t1.answer = 'OK'"
(Needs parenthese around it, or \ at line ends, of course).
> What's wrong with...
> query = """select what, when, where, why
> from t1, t2, t3
> where t1.id = t2.id_t1
> and t3_id2 = t2.id ...etc """
You can't intersperse comments in this way -- not a problem when
the string is simple enough, but some SQL queries can be pretty
complicated AND not all SQL dialects let you insert comments in
the query itself.
More information about the Python-list