[sqlalchemy] Selecting what properties of an object will be loaded

2008-10-16 Thread Alex K
Hi All, I wonder if there is a way to set what columns of the object will be used during this particular query, to reduce the query in case if I need the object, but I don't need all object properties. is something like this: session.query(User).load('column_a') possible? session.query([...])

[sqlalchemy] Re: Selecting what properties of an object will be loaded

2008-10-16 Thread Alex K
That's fine, but I'd like to do the same for columns On 16 окт, 13:50, [EMAIL PROTECTED] wrote: for relations, u can put deferred(name) and noload(name) in quety.options( ...). no idea for plain columns On Thursday 16 October 2008 12:56:19 Alex K wrote: Hi All, I wonder if there is a

[sqlalchemy] How are connections managed?

2008-10-16 Thread Heston James - Cold Beans
Afternoon Guys, I have a suspicion that I'm leaving MySQL database connections open when I shouldn't be and I'm trying to understand how they are managed by SQLAlchemy. I currently create an engine instance and bind my session maker too it like this: # Create the engine to

[sqlalchemy] Re: connect data base

2008-10-16 Thread victoria
Make sure you have these lines in pg_hba.conf: hostall all 127.0.0.1/32 password hostall all ::1/128 password thank you very much for help, with this change I can resolved a problem 1- after any thing we must change in the

[sqlalchemy] Re: Selecting what properties of an object will be loaded

2008-10-16 Thread az
for relations, u can put deferred(name) and noload(name) in quety.options( ...). no idea for plain columns On Thursday 16 October 2008 12:56:19 Alex K wrote: Hi All, I wonder if there is a way to set what columns of the object will be used during this particular query, to reduce the query

[sqlalchemy] Re: Selecting what properties of an object will be loaded

2008-10-16 Thread Ants Aasma
With session.query(User).options(undefer(User.column_a), defer(User.column_b), noload(User.column_c)) column_a will be loaded with the query, column_b will be loaded on access and column_c will be None regardless of the value in the database. Ants On Oct 16, 12:56 pm, Alex K [EMAIL PROTECTED]

[sqlalchemy] Problem with func and string concatenation

2008-10-16 Thread Adam
I'm using Postgres 8.3 and sqlalchemy 0.5.0rc2 - when I'm doing a select, it seems I can't concatenate a function with another column - rather that use the || operator, it tries to use the || operator. Code to reproduce example: import sqlalchemy as sa from sqlalchemy import * from

[sqlalchemy] duplicated sql ? - why?, speeding up relations (slow)

2008-10-16 Thread g00fy
I have loads of related fields in my model. I set up lazy = False where i had to and i don't know why SA keeps duplicating (aliasing) my tables, so i fetch my data twice (2 times more column that i realy need) i send my model and mappings and the sql code SA is querying. models:

[sqlalchemy] Re: duplicated sql ? - why?, speeding up relations (slow)

2008-10-16 Thread Michael Bayer
On Oct 16, 2008, at 12:31 PM, g00fy wrote: I have loads of related fields in my model. I set up lazy = False where i had to and i don't know why SA keeps duplicating (aliasing) my tables, so i fetch my data twice (2 times more column that i realy need) i send my model and mappings and

[sqlalchemy] Re: duplicated sql ? - why?, speeding up relations (slow)

2008-10-16 Thread g00fy
So in simple words, how do I speed this up? On 16 Paź, 18:42, Michael Bayer [EMAIL PROTECTED] wrote: On Oct 16, 2008, at 12:31 PM, g00fy wrote: I have loads of related fields in my model. I set up lazy = False where i had to and i don't know why SA keeps duplicating (aliasing) my

[sqlalchemy] Mod_python problem

2008-10-16 Thread Tiago Becker
Hello. I'm trying to use sqlalchemy with mod_python, but im getting a strange behavior when i try to use the function sessionmaker. Here is the error: AttributeError: 'module' object has no attribute 'sessionmaker' on the line: Session = sqlalchemy.orm.sessionmaker(autoflush=False,

[sqlalchemy] Re: duplicated sql ? - why?, speeding up relations (slow)

2008-10-16 Thread Michael Bayer
On Oct 16, 2008, at 1:23 PM, g00fy wrote: I do have correct results, but this is very slow. I assume that I have to query(Model) whitout any relations and then eagerload or join or whatever that will make this work for me. Am i right that mapper's lazy=False is not good for this

[sqlalchemy] Re: duplicated sql ? - why?, speeding up relations (slow)

2008-10-16 Thread g00fy
you are right, the generated sql is fast, but the fetching from results is slow due the large ammount of columns (at least 100). I don't know now what to use :/ generaly i will use all of the columns that i fetch, including related objects, so everything is needed. any sugestions? On 16 Paź,