[sqlalchemy] Re: merge() expires attributes

2010-02-23 Thread Kent
Thanks, and I knew I had brought up similar behavior before, but it was in the context of merge() by itself (with composite primary keys). Before I was wondering why merge expires columns that merge() originally fetched. This seemed like a different issue to me on the surface, because in this

Re: [sqlalchemy] Re: merge() expires attributes

2010-02-23 Thread Michael Bayer
On Feb 23, 2010, at 7:28 AM, Kent wrote: Thanks, and I knew I had brought up similar behavior before, but it was in the context of merge() by itself (with composite primary keys). Before I was wondering why merge expires columns that merge() originally fetched. This seemed like a different

[sqlalchemy] Multiple relations to the same table in a base declarative class causes errors when querying

2010-02-23 Thread Oliver Beattie
Hi all, I've run into something I can't for the life of me work out why is happening. I've done a quick search and can't find anything. Basically, I have a base class that is subclassed (single table inheritance) with two relations both pointing to one other table. I'm probably confusing as hell,

[sqlalchemy] How to make relation to same table

2010-02-23 Thread flya flya
here is code: Base = declarative_base() class Page(Base): __tablename__ = 'pages' id = Column(Integer, primary_key=True) parent_id = Column('parent_id', Integer, ForeignKey('pages.id')) children = relation('Page', backref='parent') I get error information:

Re: [sqlalchemy] another problem with complex join

2010-02-23 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: On Feb 18, 2010, at 11:55 AM, Manlio Perillo wrote: Michael Bayer ha scritto: [...] so what I had in mind is that, if its given a join as the left side, it just does the natural thing, i.e. joins to the right. If

Re: [sqlalchemy] Multiple relations to the same table in a base declarative class causes errors when querying

2010-02-23 Thread Michael Bayer
On Feb 23, 2010, at 1:03 PM, Oliver Beattie wrote: Hi all, I've run into something I can't for the life of me work out why is happening. I've done a quick search and can't find anything. Basically, I have a base class that is subclassed (single table inheritance) with two relations both

[sqlalchemy] Joining an Aliased Table Ignored

2010-02-23 Thread Affect
Hi: I apologize if this is covered in a previous post; it's hard to articulate a search for it! I have a table that references itself and another table. The respective models are Work and Owner. So a Work has a foreign key reference to itself (i.e., to its parent) and another to Owner. I have

[sqlalchemy] Correlated sub-query as ORM query filter

2010-02-23 Thread David Bolen
Hopefully this won't just be a section in the manual I missed, but I'm having some difficulties constructing an ORM query while using correlated sub-queries within filter(). This is with SA 0.5.8. Given the following tables (with just the relevant columns shown): attendance (

Re: [sqlalchemy] Correlated sub-query as ORM query filter

2010-02-23 Thread Michael Bayer
On Feb 23, 2010, at 5:23 PM, David Bolen wrote: But various attempts to use these queries in a filter() portion of the original query always result ArgumentError exception that filter() argument must be of type sqlalchemy.sql.ClauseElement or string I figured I'm missing some magic method

Re: [sqlalchemy] Joining an Aliased Table Ignored

2010-02-23 Thread Michael Bayer
On Feb 23, 2010, at 4:45 PM, Affect wrote: work1 = aliased(Work) work2 = aliased(Work) query = session.query(work1).outerjoin((work2, work1.parent)) query = query.outerjoin((Owner, work1.owner)) bug confirmed, this is ticket #1706. for now workaround explicitly: query =

[sqlalchemy] reflecting schema just on a single table

2010-02-23 Thread Paul Rigor (uci)
Hi, Is there anyway to use a metadata object just to obtain the schema of a single table? I have a database of hundreds of tables, and calling MetaData.reflect() retrieves the schema for all of the tables. This unnecessarily uses up memory and incurs additional time for i/o to complete. Thanks,

[sqlalchemy] Re: Correlated sub-query as ORM query filter

2010-02-23 Thread David Bolen
Michael Bayer mike...@zzzcomputing.com writes: if the issue is that you have a query(), and you like to say somequery.filter(q == x), you'd turn query() into a subquery (i.e. an alisaed SQLAlchemy expression object) using q.subquery(), and then into a scalar subquery using as_scalar(), which

Re: [sqlalchemy] Joining an Aliased Table Ignored

2010-02-23 Thread Michael Bayer
On Feb 23, 2010, at 5:57 PM, Michael Bayer wrote: On Feb 23, 2010, at 4:45 PM, Affect wrote: work1 = aliased(Work) work2 = aliased(Work) query = session.query(work1).outerjoin((work2, work1.parent)) query = query.outerjoin((Owner, work1.owner)) bug confirmed, this is ticket

Re: [sqlalchemy] Re: Correlated sub-query as ORM query filter

2010-02-23 Thread Michael Bayer
On Feb 23, 2010, at 7:35 PM, David Bolen wrote: Michael Bayer mike...@zzzcomputing.com writes: if the issue is that you have a query(), and you like to say somequery.filter(q == x), you'd turn query() into a subquery (i.e. an alisaed SQLAlchemy expression object) using q.subquery(), and

[sqlalchemy] New H2 dialect

2010-02-23 Thread Tal
Hi group! I would like to contribute a dialect for the wonderful H2 database: http://www.h2database.com/ For those who don't know it, H2 is a JVM-based database with similar performance characteristics and footprint to SQLite, but with many more features, including hosted mode, cluster mode,

[sqlalchemy] New dialect -- Why am I getting rollbacks?

2010-02-23 Thread Tal
I've created a new dialect (for the H2 database), but it seems to work OK only when I explicitly turn on auto-commit, this: def do_begin(self, connect): cu = connect.cursor() cu.execute('SET AUTOCOMMIT ON') H2 does support transactions, and I would like them enabled. However,

[sqlalchemy] Re: Multiple relations to the same table in a base declarative class causes errors when querying

2010-02-23 Thread Oliver Beattie
Ah, thanks so much. Guess sometimes you just need a second pair of eyes to spot where you've messed it up :) On Feb 23, 7:29 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 23, 2010, at 1:03 PM, Oliver Beattie wrote: Hi all, I've run into something I can't for the life of me work

[sqlalchemy] Re: How to make relation to same table

2010-02-23 Thread Oliver Beattie
You probably want to take a look at http://www.sqlalchemy.org/docs/05/mappers.html#adjacency-list-relationships On Feb 23, 5:42 pm, flya flya flyafl...@gmail.com wrote: here is code: Base = declarative_base() class Page(Base):    __tablename__ = 'pages'    id = Column(Integer,