[sqlalchemy] joinedload(), contains_eager(), ...

2010-11-30 Thread Julien Cigar
Hello, I'm busy to update an application to the last SQLAlchemy version. I have to following mapped object, with a relation: orm.mapper(Image, table.images, properties = { 'owner' : orm.relationship( Participant, uselist = False ) }) In previous version of SQLAlchemy I

Re: [sqlalchemy] Char encoding..

2010-11-30 Thread Michael Bayer
Simple enough Blob is a binary type, not a character type. You need to put binary data in there, so in python 2x that's str, ie encode it. Direct Unicode support in sqla is via the string/Unicode types. Sent from my iPhone On Nov 29, 2010, at 8:43 PM, Warwick Prince

[sqlalchemy] Problem with one to many relationship and composite primary key

2010-11-30 Thread Mariano Mara
Hi. I'm trying to relate two tables with a one to many relationship (the parent table has a composite primary key) but I'm getting a mapper error. I found a recent message about this same problem but with declarative base (which I don't use) and not sure why the suggestion there didn't apply to

[sqlalchemy] finding if a table is already join in a query

2010-11-30 Thread James Neethling
Hi all, We have a small function that helps us create a simple search query by automatically joining on required relations if needed. For example, consider an employee ORM that has a 1:M relationship with addresses (for postal/physical). We can do something like: query =

Re: [sqlalchemy] Problem with one to many relationship and composite primary key

2010-11-30 Thread Michael Bayer
Nothing wrong with the mapping, except the primaryjoin is not needed. The cause is certainly the usage of useexisting, which implies that these tables have already been created, and everything you are specifying in the Table() is ignored. I wouldn't use that flag. On Nov 30, 2010, at

Re: [sqlalchemy] finding if a table is already join in a query

2010-11-30 Thread Michael Bayer
On Nov 30, 2010, at 11:13 AM, James Neethling wrote: Hi all, We have a small function that helps us create a simple search query by automatically joining on required relations if needed. For example, consider an employee ORM that has a 1:M relationship with addresses (for

Re: [sqlalchemy] Problem with one to many relationship and composite primary key

2010-11-30 Thread Mariano Mara
Excerpts from Michael Bayer's message of Tue Nov 30 13:50:26 -0300 2010: Nothing wrong with the mapping, except the primaryjoin is not needed. The cause is certainly the usage of useexisting, which implies that these tables have already been created, and everything you are specifying in the

Re: [sqlalchemy] Problem with one to many relationship and composite primary key

2010-11-30 Thread Michael Bayer
your RegEvent mapper is against the wrong table, here is the correct code: from sqlalchemy import * from sqlalchemy.orm import * metadata = MetaData() regevent = Table('regevent', metadata, Column('id', Unicode(200), primary_key=True), Column('author',

Re: [sqlalchemy] Problem with one to many relationship and composite primary key

2010-11-30 Thread Mariano Mara
ohhh, I'm out of words other than thank you for spotting it. I can't believe how stupid I feel right now. Mariano Excerpts from Michael Bayer's message of Tue Nov 30 14:27:42 -0300 2010: your RegEvent mapper is against the wrong table, here is the correct code: from sqlalchemy import * from

[sqlalchemy] How can I do this relation?

2010-11-30 Thread Alvaro Reinoso
Hello, I have this table: class Region(rdb.Model): Represents one region in the layout rdb.metadata(metadata) rdb.tablename(regions) id = Column(id, Integer, primary_key=True) title = Column(title, String(50)) .. channelId =

Re: [sqlalchemy] finding if a table is already join in a query

2010-11-30 Thread James Neethling
On Tue, 2010-11-30 at 11:52 -0500, Michael Bayer wrote: On Nov 30, 2010, at 11:13 AM, James Neethling wrote: Hi all, We have a small function that helps us create a simple search query by automatically joining on required relations if needed. For example, consider an employee ORM

Re: [sqlalchemy] session.execute(sql_statement) does not flush the session in a autoflush=True session ?

2010-11-30 Thread James Neethling
On Fri, 2010-11-26 at 15:41 -0500, Michael Bayer wrote: I wouldn't say its a bug since its intentional. But I'll grant the intention is up for debate. I've always considered usage of execute() to mean, you're going below the level of the ORM and would like to control the SQL interaction