[sqlalchemy] prevent extra selects to get default values

2010-06-21 Thread GHZ
Hi, If I create a table with a default. create table T (id number primary key, data number default NULL) Then reflect this table. then using the ORM I trigger an insert, but only into the id column and flush() then I try to access the 'data' attribute this causes a select, to get the actual

[sqlalchemy] Re: prevent extra selects to get default values

2010-06-21 Thread GHZ
including small example in the actual case, I can't find anything as obvious as the equivalent of 'print t.data' in my code.. but something is triggering these selects of columns with defaults from sqlalchemy import MetaData, create_engine, Table, Column, Integer from sqlalchemy.orm import

[sqlalchemy] Storing an object that has only private attributes

2010-06-21 Thread Samuel
Hi, I am looking for a way to store a non-sqlalchemy aware object in the database, something like this: class Foo(object): def __init__(self, name): self.__name = name self.__map = {} def set_name(self, name): self.__name = name def get_name(self):

[sqlalchemy] Re: modifying a field

2010-06-21 Thread Aref
Thank you so much. That worked. I was staring at the SQLsoup doc you linked to for hours trying to understand but could not figure what the _ meant. In any case your explanation is clear and very useful. Thanks again. On Jun 20, 5:18 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jun 20,

Re: [sqlalchemy] Re: prevent extra selects to get default values

2010-06-21 Thread Michael Bayer
what do you want p.data to return ?leaving it undefined is enough for the ORM to consider it as unloaded. Your best option here would be just to not map the column (see the exclude_columns argument for that). On Jun 21, 2010, at 5:48 AM, GHZ wrote: including small example in the

[sqlalchemy] Re: is it possible to limit a session.query() to return only certain columns - not orm objects ?

2010-06-21 Thread Jonathan Vanasco
On Jun 20, 9:41 pm, Michael Bayer mike...@zzzcomputing.com wrote: its for a scalar:http://www.sqlalchemy.org/docs/reference/orm/query.html?highlight=que... I had read that, but it was unclear. Initially I thought that scalar meant a single column. ie: values(foo.bar) = ((17,),(18,)) ;

Re: [sqlalchemy] Can SQLAlchemy's ORM do this?

2010-06-21 Thread Michael Bayer
yes please see the polymorphic association example included in the distribution . On Jun 21, 2010, at 3:44 PM, Ryan I. wrote: How would one go about modeling a relationship where one class can be a child of many classes. For example, let's say I have a lot of classes like this: class

[sqlalchemy] problem with select([table.c.column1, table.c.column1])

2010-06-21 Thread Jon Nelson
I'm encountering a problem with SA 0.6.1 I have a select statement which selects the same column twice (and some other stuff, too). However, when the query is run (or printed), the column only shows up once. This seems like a bug. Example: from sqlalchemy import create_engine, select, Table,

Re: [sqlalchemy] problem with select([table.c.column1, table.c.column1])

2010-06-21 Thread Michael Bayer
not a bug, that's the correct behavior. On Jun 21, 2010, at 5:35 PM, Jon Nelson wrote: I'm encountering a problem with SA 0.6.1 I have a select statement which selects the same column twice (and some other stuff, too). However, when the query is run (or printed), the column only shows up

[sqlalchemy] Re: Can SQLAlchemy's ORM do this?

2010-06-21 Thread Ryan I.
On Jun 21, 10:02 pm, Michael Bayer mike...@zzzcomputing.com wrote: yes please see the polymorphic association example included in the distribution . Thanks! It seems there's nothing SQLAlchemy can't do :). Btw, since the examples are a bit complicated, here is just for reference in case

Re: [sqlalchemy] problem with select([table.c.column1, table.c.column1])

2010-06-21 Thread Jon Nelson
On Mon, Jun 21, 2010 at 5:55 PM, Michael Bayer mike...@zzzcomputing.com wrote: not a bug, that's the correct behavior. Can you explain how it is correct? I asked for two things but I only got one. Why should it matter if they happen to be the /same/ thing? In this particular case, I need it for