Re: [SQLObject] Using SQLBuilder to create a queryAll custom query

2006-04-20 Thread Oleg Broytmann
On Fri, Apr 21, 2006 at 01:01:51AM +0400, Oleg Broytmann wrote: > On Thu, Apr 20, 2006 at 02:39:48PM -0600, Gabe Rudy wrote: > > connection.sqlrepr(Select(...)) is preferred over str(Select(...)) then is > > it? > >str(Select()) can raise an exception because str() doesn't pass a > database n

Re: [SQLObject] Using SQLBuilder to create a queryAll custom query

2006-04-20 Thread Oleg Broytmann
On Thu, Apr 20, 2006 at 02:39:48PM -0600, Gabe Rudy wrote: > connection.sqlrepr(Select(...)) is preferred over str(Select(...)) then is it? str(Select()) can raise an exception because str() doesn't pass a database name to __sqlrepr__() internal methods. connection.sqlrepr() passes it correctly

Re: [SQLObject] Using SQLBuilder to create a queryAll custom query

2006-04-20 Thread Gabe Rudy
Cool, there is no special reason why I need to use tuples, so I'm just glad I got something to work. connection.sqlrepr(Select(...)) is preferred over str(Select(...)) then is it? Thanks for that quick response on my question Oleg, I actually did'nt get yours untill after I responded to my own

Re: [SQLObject] Using SQLBuilder to create a queryAll custom query

2006-04-20 Thread Luke Opperman
sqlbuilder.Select looks like it's supposed to handle lists or tuples (although yes, by type-checking). And then in __sqlrepr__ it appears it is using things = self.items[:] Presumably this is intended a) to make a copy so that appending to things doesn't update self.items and b) to cast to a lis

Re: [SQLObject] Using SQLBuilder to create a queryAll custom query

2006-04-20 Thread Gabe Rudy
> >str(Select((Contact.q.id, Contact.q.firstName, Company.q.companyName), > Contact.q.companyID == Company.q.id)) > File "", line 1, in ? > ... > "/usr/lib/python2.4/site-packages/SQLObject-0.8dev_r1706-py2.4.egg/sqlobjec >t/sqlbuilder.py", line 452, in __sqlrepr__ > things.append(self.whereC

Re: [SQLObject] Using SQLBuilder to create a queryAll custom query

2006-04-20 Thread Oleg Broytmann
On Thu, Apr 20, 2006 at 12:44:39PM -0600, Gabe Rudy wrote: > >str(Select((Contact.q.id, Contact.q.firstName, Company.q.companyName), > AttributeError: 'tuple' object has no attribute 'append' The first arg should be a list, I think: Select([Contact.q.id, Contact.q.firstName, Company.q.companyN

Re: [SQLObject] Bad use of sqlhub.getConnection?

2006-04-20 Thread Oleg Broytmann
On Thu, Apr 20, 2006 at 11:35:01AM -0700, Erik Stephens wrote: > I'm getting weird, sporadic results from some of my legacy queries. > I'm using sqlhub.getConnection().getConnection() to get a cursor and > execute queries the old-fashioned way. The old-fashioned way in SQLObject is connec

[SQLObject] Using SQLBuilder to create a queryAll custom query

2006-04-20 Thread Gabe Rudy
Hey, I'm trying to optimized a selection of 3000+ items and due to some of the overhead of inheritance of SQLObject, I want to do a very specific query. I like the idea of using SQLBuilder to generate the query string, but ran into a bit of a problem. It may be that I don't understand the prope

[SQLObject] Bad use of sqlhub.getConnection?

2006-04-20 Thread Erik Stephens
I'm getting weird, sporadic results from some of my legacy queries. I'm using sqlhub.getConnection().getConnection() to get a cursor and execute queries the old-fashioned way. Is that a no-no? The problem I'm seeing is that sometimes the records are retrieved and sometimes they're not, e

Re: [SQLObject] Inheritence and validation

2006-04-20 Thread Peter Butler
The obvious solution seems to be to do some pre-validation is there a way to get a list of all the keyword arguments expected by a professor Object? I use something like this (in SQLObject 0.6.1, not sure if it will work in later versions): initValues = {} # populate with values that you

Re: [SQLObject] RelatedJoin efficiency

2006-04-20 Thread Luke Opperman
You could use a SQLRelatedJoin, and then do: coll.members.count() - Luke Quoting Oleg Broytmann <[EMAIL PROTECTED]>: On Thu, Apr 20, 2006 at 03:54:18PM +0300, Max Ischenko wrote: Is there a way to use a COUNT(*) query in context like these? There is no currently. Oleg. -- Oleg Bro

Re: [SQLObject] RelatedJoin efficiency

2006-04-20 Thread Oleg Broytmann
On Thu, Apr 20, 2006 at 03:54:18PM +0300, Max Ischenko wrote: > Is there a way to use a COUNT(*) query in context like these? There is no currently. Oleg. -- Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED] Programmers don't die, they just GOSUB withou

[SQLObject] RelatedJoin efficiency

2006-04-20 Thread Max Ischenko
Hi, I have two tables that are related via intermediate tables (expressed with RelatedJoin in SQLObject): class Collection(SQLObject): members = RelatedJoin(...) when I evaluating expr like len(coll.members) or "if not coll.members" it seems to actually fetch (and discard) some data from d

Re: [SQLObject] Inheritence and validation

2006-04-20 Thread Oleg Broytmann
On Thu, Apr 20, 2006 at 10:47:40AM +1000, konrad Zielinski wrote: > Role(InheritableSQLObject) > Staff(Role) > Professor(Staff) > > due to keyword errors the system sucesfully ceated a Role instance and > Staff instance but failed to create a professor instance. Use transactions and rollback o

Re: [SQLObject] Re: Selecting from JOINed tables

2006-04-20 Thread Oleg Broytmann
On Thu, Apr 20, 2006 at 12:00:41AM +, Mike wrote: > The output I'm looking for is something like > SELECT call.col1, call.col2 call.coln, make.col1 ... make.coln FROM make, > call WHERE ((... SQLObject manipulates with *objects*. If you have a table and do MyTable.select()