[sqlalchemy] Obtaining primitive columns from a select

2008-07-15 Thread Lele Gaifax
Hi all, I'd like to have a generic function that executes a given SQL query filtering it with conditions passed as keyword args, but I do not find a clean way to refer to the primitive columns (on the underlying table) instead of those already bound to the select. Given a simple select::

[sqlalchemy] Re: M2M relationship

2008-07-15 Thread Heston James - Cold Beans
Hi Michael, create a file called something like globals.py, and in all other modules that use SQLAlchemy, say import globals. A primer on modules, packages and such is at http://www.python.org/doc/tut/node8.html Excellent! This seems to have done the job, I am now successfully

[sqlalchemy] Filter by optional attributes.

2008-07-15 Thread Heston James - Cold Beans
Good morning guys, I'm looking for a way in which I can query my database for records which meet multiple, optional arguments. I'm looking to encapsulate access to this using a service layer, I want to create a method like this: def get_foos(self, foo_id=, foo_firstname=,

[sqlalchemy] Re: Filter by optional attributes.

2008-07-15 Thread az
use keywordargs as dictionary, i.e. ...query.filter( **kwargs) where the kwargs are a dict made by u containing only the required fields. e.g. kwargs={} if foo_id: kwargs['fooid']=fooid ... u can make it more generic (but more dangerous) by passing any kwargs coming to your func straight down

[sqlalchemy] Re: Filter by optional attributes.

2008-07-15 Thread Heston James - Cold Beans
Hi Svil: use keywordargs as dictionary, i.e. ...query.filter( **kwargs) where the kwargs are a dict made by u containing only the required fields. e.g. kwargs={} if foo_id: kwargs['fooid']=fooid That sounds like a fair enough solution to me, seems safer than the more generic version.

[sqlalchemy] Re: Filter by optional attributes.

2008-07-15 Thread Heston James - Cold Beans
Hello Again Svil: That sounds like a fair enough solution to me, seems safer than the more generic version. Thanks for the tip mate, sounds really great. I'll play around with that concept. Heston I've tested this little concept and it works really nicely :-D thanks. One quick question

[sqlalchemy] Re: Filter by optional attributes.

2008-07-15 Thread Heston James - Cold Beans
Hi, pass an echo=True to the create_engine() (or whereever else u could pass that) and u'll see the sql. Ok, I see! Perfect! I've just configured logging on this so I can keep track, looks excellent. Heston --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Injecting business objects into constructor

2008-07-15 Thread Heston James - Cold Beans
Afternoon Guys, In my classic non-orm based applications I would usually inject other business object instances into my classes for such things as logging, emailing and all manner of other things. For instance: class foo: def __init__(self, logger, email_service, foo_id=,

[sqlalchemy] Re: unexpected behavior with relation and filter_by

2008-07-15 Thread Michael Bayer
On Jul 14, 2008, at 7:19 PM, Jon wrote: I've encountered some weird stuff. I'm probably doing it wrong, but I don't understand *why*. The following code: s = Session() # returns all accounts, the .licenses param # not taken into consideration accts =

[sqlalchemy] Bug in 0.4.6/0.5 ?

2008-07-15 Thread Stefano Bartaletti
Hello list, I recently installed 0.4.6 to check the news, and with horror I saw this dump: Traceback (most recent call last): File /media/userdata/stefano/Documenti/projects/Tosi/erp/login.py, line 85, in onCheckUtente self.checkUtente(self.inputUser.GetValue().lower()) File

[sqlalchemy] Bug in 0.4.6/0.5 ?

2008-07-15 Thread Stefano Bartaletti
I recently installed 0.4.6 to check the news, and with horror I saw this dump: Traceback (most recent call last): File /media/userdata/stefano/Documenti/projects/Tosi/erp/login.py, line 85, in onCheckUtente self.checkUtente(self.inputUser.GetValue().lower()) File

[sqlalchemy] Re: Bug in 0.4.6/0.5 ?

2008-07-15 Thread Michael Bayer
Did you call something like select([literal('foo')]) ?If you use straight Python literals in the columns clause (i.e. select(['foo'])), they will be rendered directly, which is probably what you want here. This is fixed in r4933 / r4934 0.5 trunk/ 0.4 branch. On Jul 15, 2008, at 10:52

[sqlalchemy] Re: session.dirty but not session.is_modified....

2008-07-15 Thread Michael Bayer
popping from dirty() wont change anything since its a set thats generated each time it's called. this is from the doc for dirty(): Note that this 'dirty' calculation is 'optimistic'; most attribute-setting or collection modification operations will mark an

[sqlalchemy] Re: srid autodiscovery mechanism

2008-07-15 Thread jason kirtland
Michael Bayer wrote: On Jul 13, 2008, at 5:42 PM, Eric Lemoine wrote: So far, so good; user can do: wifi_table = Table('wifi', metadata, Column('the_geom', Geometry(4326)), autoload=True) But ultimately I'd like that my users can do: wifi_table = Table('wifi', metadata,

[sqlalchemy] Re: Injecting business objects into constructor

2008-07-15 Thread Rick Morrison
I'm not sure where this is going with the 0.5 version, but I believe that MappedClass.__int__ is still not called when objects are loaded from the DB. If that's the case, and there isn't some alternate that SA provides like MappedClass.__onload__, You can look into Mapper Extensions to provide

[sqlalchemy] Load capabilities with default pool_size and max_overflow

2008-07-15 Thread Fotinakis
Hello SQLAlchemists, What is (or what do you think is) the load that SQLAlchemy can handle with the default engine options of pool_size=5 and max_overflow=10? The application I'm working on has the potential for bursts of thousands of requests in a few seconds, so I am concerned about load. Is

[sqlalchemy] Re: Load capabilities with default pool_size and max_overflow

2008-07-15 Thread Andreas Jung
--On 15. Juli 2008 22:32:35 -0700 Fotinakis [EMAIL PROTECTED] wrote: Hello SQLAlchemists, What is (or what do you think is) the load that SQLAlchemy can handle with the default engine options of pool_size=5 and max_overflow=10? The application I'm working on has the potential for bursts of