On Thu, Jan 8, 2009 at 12:31 AM, inhahe <inhahe@gmail.com> wrote:
Oops, I thought I had tried that and that it didn't work (and I didn't
see the documentation explicitly mention calling select with no
parameters), but it just didn't work due to something I had missed
elsewhere.  Thanks.

====== 8< ==========
from sqlobject import *
from sqlobject.sqlbuilder import *
connInMem = connectionForURI('sqlite:/:memory:')

sqlhub.processConnection = connectionForURI('sqlite:/:memory:')
class Person(SQLObject):
    fname = StringCol()
    mi = StringCol(length=1, default=None)
    lname = StringCol()

Person.createTable()
Person(fname="John", lname="Doe")
Person(fname="John", lname="Doe")
Person(fname="Inhahe", lname="Noname")
Person(fname="Inhahe", lname="Noname")

Person._connection.debug = True
returnedValues = connInMem.queryAll("SELECT DISTINCT person.fname, person.mi, person.lname from person")
print returnedValues
====== 8< ==========

Following code generates valid SQL query, but because id column is included, it returns all rows from the database (id is unique for each row).

for row in Person.select().distinct():
    print row

I do not know, if it is possible to force SQLObject not to include person.id column in to the select query, but I guess no (maybe Oleg can help).

Regards

Petr