On Thu, Feb 09, 2006 at 06:05:29PM -0800, Mike Orr wrote:
> I can see the SQL in my head and could just do connection.queryAll with:
>     SELECT Chemical.id AS id, Name.name AS name
>     FROM Chemical, Chemical_Name, Name
>     WHERE Chemical.id = Chemical_Name.Chemical_id
>     AND Name.id = Chemical_Name.Name_id
>     AND Chemical.canonical_nameID = Name.id
>     AND Name.name LIKE 'A%'
>     ORDER BY 2
> 
> But I'm looking for more SQLObject-ish alternatives.

   http://svn.colorstudy.com/SQLObject/docs/FAQ.txt

"What about GROUP BY, UNION, etc?"

   "In short - not every query can be represented in SQLObject..."

> There's a Select object mentioned in "How to use database agnostic SQL
> in SQLObject", but it doesn't seem to be officially documented.

   It is not "officially" documented not because it is "internal" but
because SQLObject desperately needs documentation writers!

> I played with that and got:
> 
> >>> sql = conn.sqlrepr(Select([Chemical.q.id, Name.q.name],
> where=AND(Name.q.name.startswith('A'), Chemical.q.canonical_nameID ==
> Name.q.id),orderBy=Name.q.name))
> >>> sql
> "SELECT Chemical.id, Name.name FROM Chemical, Name WHERE ((Name.name
> LIKE 'A%') AND (Chemical.canonical_nameID = Name.id)) ORDER BY
> Name.name"
> >>> conn.queryAll(sql)
> ( tuple of several 2-tuples listed )
> 
> => That works.  I guess that's what I want.  Any other ideas?

   That's what you want, and it works, and it's SQLObject-ish enough...

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to