On Mon, Nov 08, 2010 at 09:53:26PM +0000, AlexB wrote:
> I have a specific SQL query that I need:
>
> select distinct author from blogtable where keyword = "dust";
One cannot select a column using the high-level SQLObject API, one can
only select all columns at once (*), and it's almost meaningless to query
select distinct *
SQLBuilder is the mid-level API. To use SQLBuilder first construct the
query:
from sqlobject.sqlbuider import Select
query = Select([BlogTable.q.author], where=BlogTable.q.keyword=='dust',
distinct=True)
and then convert the object to SQL query string and execute the string
using the low-level API:
rows = connection.queryAll(connection.sqlrepr(query))
The result is a list of rows, every row is a tuple of length 1 (the
author):
for row in rows:
author = row[0]
print author
Oleg.
--
Oleg Broytman http://phd.pp.ru/ [email protected]
Programmers don't die, they just GOSUB without RETURN.
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss