[sqlalchemy] Re: ORM lifecycle questions

2008-12-17 Thread Michael Bayer
On Dec 17, 2008, at 11:32 AM, Ross Vandegrift wrote: On Thu, Dec 11, 2008 at 02:59:39PM -0500, Michael Bayer wrote: On Dec 11, 2008, at 2:04 PM, Ross Vandegrift wrote: So if I do something like this: p = meta.session.query(model.Pool) pool = p.get(7) meta.session.refresh(pool)

[sqlalchemy] Re: setting up insert many stmt?

2008-12-17 Thread Michael Bayer
On Dec 17, 2008, at 8:18 AM, Max Ischenko wrote: Hello, I'm having trouble doing insertmany correctly. I read the docs and came up with this code: s = Session() ins = data_tbl.insert() records = [] for rec in s.execute(sql).fetchall():

[sqlalchemy] Re: ORM lifecycle questions

2008-12-17 Thread Ross Vandegrift
On Thu, Dec 11, 2008 at 02:59:39PM -0500, Michael Bayer wrote: On Dec 11, 2008, at 2:04 PM, Ross Vandegrift wrote: So if I do something like this: p = meta.session.query(model.Pool) pool = p.get(7) meta.session.refresh(pool) InvalidRequestError: Instance 'p...@0xa6aca8c' is not

[sqlalchemy] speed eficiency

2008-12-17 Thread sagblmi
Hi, A very simple question... Context: * I only need to retrieve values from a table * I've a mapper object for the table Question: In a performance point a view which is the more suitable method: - mappers = session.query(User).filter_by(name='ed').all() or - results =

[sqlalchemy] Re: Abstract base class

2008-12-17 Thread Michael Bayer
On Dec 17, 2008, at 2:28 AM, Joril wrote: Michael Bayer ha scritto: concrete inheritance, as referenced in that post, was not designed to be used as a configurational spacesaver and always requires a mapped selectable for the base, which you don't have here, so it's not appropriate for

[sqlalchemy] reflection for indices, function-based indices

2008-12-17 Thread Diez B. Roggisch
Hi, we've got some function-based indices we currently create using plain text()-calls, like this: CREATE UNIQUE INDEX users_lower_email_index ON user_db.users (lower(email)); This works, but it would be nice to stay in the SA-world even with these

[sqlalchemy] Re: Vague InterfaceError (threading issue?) running normal query

2008-12-17 Thread Michael Bayer
On Dec 17, 2008, at 10:10 AM, Ken wrote: Actually, I found that the error goes away if I don't set pool_recycle=True. However, I'm told pool_recycle is necessary to prevent MySQL has gone away errors. yes but pool_recycle is documented as a number of seconds, and a typical value is 3600

[sqlalchemy] exceptions.ArgumentError when trying to map class to a table

2008-12-17 Thread Nathan Harmston
Hi everyone , I have the following setup (snipped): in_table = Table('in', metadata, Column('id', Integer, primary_key=True), Column('pA', String(6), ForeignKey('p.id'), nullable=False), Column('pB', String(6), ForeignKey('p.id'),

[sqlalchemy] association( viewonly ) bug?

2008-12-17 Thread az
i found some discrepancies which may or may not be a bug. When a many2many implicit assoc via secondary_table is setup with view_only=True: a) proploader.remote_side contains only the primaryjoin item (which is probably ok, i dont know what it's used for), so i have to dig

[sqlalchemy] Re: reflection for indices, function-based indices

2008-12-17 Thread Michael Bayer
On Dec 17, 2008, at 6:36 AM, Diez B. Roggisch wrote: Hi, we've got some function-based indices we currently create using plain text()-calls, like this: CREATE UNIQUE INDEX users_lower_email_index ON user_db.users (lower(email)); This works,

[sqlalchemy] setting up insert many stmt?

2008-12-17 Thread Max Ischenko
Hello, I'm having trouble doing insertmany correctly. I read the docs and came up with this code: s = Session() ins = data_tbl.insert() records = [] for rec in s.execute(sql).fetchall(): records.append(rec) ins.execute(records) It gives an

[sqlalchemy] Re: Vague InterfaceError (threading issue?) running normal query

2008-12-17 Thread Ken
Actually, I found that the error goes away if I don't set pool_recycle=True. However, I'm told pool_recycle is necessary to prevent MySQL has gone away errors. My guess then is that SQLAclehmy preparing a statement, it works right the first time, and thereafter there is an issue with it. So

[sqlalchemy] Re: simulation/synonim of a relation?

2008-12-17 Thread az
for the record, if anyone wants doing such stuff: there is a many to one reference A.b to B. one day it becomes bitemporal, i.e. an association A.b to B via A2B table, which contains other columns that cannot be invented by default values (timestamps, disabled, etc). Hence, the association

[sqlalchemy] how to maping single-table inheritance using declarative

2008-12-17 Thread Jeffrey
below is ext.declarative.py's doc: class Person(Base): __tablename__ = 'people' id = Column(Integer, primary_key=True) discriminator = Column(String(50)) __mapper_args__ = {'polymorphic_on': discriminator} class Engineer(Person): __tablename__ =

[sqlalchemy] Re: how to maping single-table inheritance using declarative

2008-12-17 Thread Michael Bayer
all Column objects have to be on the base class if you're using single table inheritance. declarative joins the Table and class definitions together, and the base class has to represent the Table completely. On Dec 17, 2008, at 10:36 PM, Jeffrey wrote: below is ext.declarative.py's doc: