[sqlalchemy] mssql, pyodbc and rowcount

2008-05-01 Thread Saibot
Hi, I am using mssql with pyodbc and stumbled over the following behaviour: meta.Session.execute(meta.metadata.tables.get(table).select()).rowcount -1 Can anybody explain what I have to do (if possible at all) to get the correct number of rows in my cursor? Thanks in advance, Tobias

[sqlalchemy] Re: mssql, pyodbc and rowcount

2008-05-01 Thread Paul Johnston
Hi, meta.Session.execute(meta.metadata.tables.get(table).select()).rowcount -1 Can anybody explain what I have to do (if possible at all) to get the correct number of rows in my cursor? I don't think you can, short of reading all the results. The reason being that pyodbc streams them from

[sqlalchemy] Re: cant update mssql table

2008-05-01 Thread adi
Hi paul thanks for the reply. i kind of solved it by removing the identity field before merging the session , this make the field take a default value from the db and thus solves my purpose regards, adi On Apr 28, 3:08 pm, Paul Johnston [EMAIL PROTECTED] wrote: Hi, a table in a mssql db

[sqlalchemy] Ordered merge of shard results (update)

2008-05-01 Thread Kyle Schaffrick
I've done some more work on this little project and have managed to produce a significantly more idiomatic version. Since it has turned into a full blown patch series, I'll save your inboxes and direct you to the whole queue at http://raidi.us/edarc/sqlalchemy This contains the iterator

[sqlalchemy] Re: Aliasing automatic joins with relation.any()

2008-05-01 Thread Yannick Gingras
Michael Bayer [EMAIL PROTECTED] writes: Although, I think it may be wise here if SQLA set the correlate value on the expression returned by any() to prevent these errors from occuring at all. Below is a patch that does it. It needs a little bit of tweaking to work with inheritance though

[sqlalchemy] Re: Session.merge vs. mapper extensions

2008-05-01 Thread Michael Bayer
On Apr 30, 2008, at 11:24 PM, Rick Morrison wrote: right, sorry, before_insert yeah if the INSERT is happening, and its in _save_obj(), the before_insert is there. theres no insert the row but dont call before_insert going on. Can you dig into it some more ?

[sqlalchemy] Re: Aliasing automatic joins with relation.any()

2008-05-01 Thread Michael Bayer
On May 1, 2008, at 10:22 AM, Yannick Gingras wrote: Is there a workaround in the mean time? Calling reset_joinpoint() after filter_by() won't do it: Item.query().join(ref_ids, aliased=True).filter_by(ref_id = OP-10)\ .reset_joinpoint().filter(not_(Item.ref_ids.any(ref_id =

[sqlalchemy] Re: Ordered merge of shard results (update)

2008-05-01 Thread Michael Bayer
On May 1, 2008, at 5:24 AM, Kyle Schaffrick wrote: There are two versions of its implementation, one based on the other. The original one tries to find mapper properties on the instances or column entities that match the expressions given. The upside is that it doesn't alter the

[sqlalchemy] Re: Aliasing automatic joins with relation.any()

2008-05-01 Thread Yannick Gingras
Michael Bayer [EMAIL PROTECTED] writes: Calling reset_joinpoint() after filter_by() won't do it that I'm not able to reproduce. If i create a similar situation which creates the same error, reset_joinpoint() turns off all the aliasing for subsequent filter() calls and then it works.

[sqlalchemy] join inheritance and mutual foreign keys behind tables

2008-05-01 Thread Bobby Impollonia
Hi. I have two tables that have foreign keys on each other. The following works fine, where Base is a declarative base: class Child1(Base): __tablename__ = 'child1' id = Column('id', Integer, primary_key=True) related_child2 = Column('c2', Integer, ForeignKey('child2.id', use_alter =

[sqlalchemy] Re: join inheritance and mutual foreign keys behind tables

2008-05-01 Thread Michael Bayer
On May 1, 2008, at 6:25 PM, Bobby Impollonia wrote: class Parent(Base): __tablename__ = 'parent' id = Column('id', Integer, primary_key=True) tp = Column('type', String(50)) __mapper_args__ = dict(polymorphic_on = tp) class Child1(Parent): __tablename__ = 'child1' id

[sqlalchemy] Join without Foreign Keys or Mappers

2008-05-01 Thread Googli S
Hello, I have two tables both of which have a userID in their primary key (one has composite primary key). There is no valid table for userID, i.e. there is no table (that I have access to) users which has a list of ALL userIDs. Now, I have records in both tables which have a userID which don't

[sqlalchemy] Re: join inheritance and mutual foreign keys behind tables

2008-05-01 Thread Michael Bayer
On May 1, 2008, at 6:25 PM, Bobby Impollonia wrote: It no longer works. In particular, I get class 'sqlalchemy.exceptions.InvalidRequestError': Could not find table 'child2' with which to generate a foreign key I actually have a fix for this in r4614, which is essentially similar to the

[sqlalchemy] Re: Join without Foreign Keys or Mappers

2008-05-01 Thread Michael Bayer
On May 1, 2008, at 8:22 PM, Googli S wrote: Hello, I have two tables both of which have a userID in their primary key (one has composite primary key). There is no valid table for userID, i.e. there is no table (that I have access to) users which has a list of ALL userIDs. Now, I have