On Mar 18, 11:25 pm, someone <petshm...@googlemail.com> wrote: > Hi, > > what is good :) style for multiline queries to database? > Is that one ok? > query = """ SELECT * FROM ( > SELECT a.columna, a.columnb, a.iso > FROM all a > WHERE (a.name = LOWER(%s)) ) AS c > JOIN other as b on c.gid = b.id > WHERE class = 'A' > ORDER BY population DESC > LIMIT %s;"""
There's no tablet of stone, like PEP 8 :-) It seems to be a matter of individual taste; clarity and consistency and not overdoing parentheses count for me. IMO you have too much leading whitespace, you have "as" in upper, lower and no case, and I'd set out the inner select differently: query = """ SELECT * FROM ( SELECT a.columna, a.columnb, a.iso FROM all AS a WHERE a.name = LOWER(%s) ) AS c JOIN other AS b ON c.gid = b.id WHERE class = 'A' ORDER BY population DESC LIMIT %s; """ Cheers, John -- http://mail.python.org/mailman/listinfo/python-list