On Apr 5, 10:17 am, "Disrupt07" <[EMAIL PROTECTED]> wrote:

> In my database I have a table users with the following columns:
>  name, surname, idcard, age, sex, dateofbirth, address, etc.
>
> In my model, I am defining the users table as follows:
>
> users_def= Table('users',
>                   metadata,
>                   schema='myschema',
>                   autoload=True
>                   )
>
> class usersobj(object):
>     pass
>
> mapper(usersobj, users_def)
>
> Now I want to query (select distinct) for the name and surname only
> (not interested in the remaining columns) using usersobj.
>
> How can I create such a query to use the usersobj object?

results = select([users_def.c.name, users_def.c.surname],
                        distinct=True).execute()

Check htttp://www.sqlalchemy.org/docs/sqlconstruction.html#sql_select_columns
for the details.

George


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to