[sqlalchemy] backref list empy

2010-08-09 Thread zzer0
Hi there. I have 2 declarative_base classes: Person and Inquiry. I have created a relationship in Inquiry with a backref to Person. When observing the an Inquiry object the person variable correctly points to Person, however when observing Person objects I always get an empty list in inquiries

[sqlalchemy] Proper way to make a TypeDecorator around Enum?

2010-08-09 Thread Nikolaj
I'm on MySQL and trying to create a type that stores enums as VARCHAR(255). However, the following code still issues an ENUM() DDL. What am I doing wrong here? class StringEnum(types.TypeDecorator): impl = types.Enum def __init__(self, *args, **kwargs): super(StringEnum,

Re: [sqlalchemy] Proper way to make a TypeDecorator around Enum?

2010-08-09 Thread Michael Bayer
TypeDecorator doesn't affect the decorated type via subclassing, it affects it via the impl attribute, hence decorates. So you say self.impl = Enum(...). You don't need to use TypeDecorator here if all you want to do is create an Enum with default arguments, just subclass Enum directly.

Re: [sqlalchemy] backref list empy

2010-08-09 Thread Michael Bayer
On Aug 9, 2010, at 5:13 AM, zzer0 wrote: Hi there. I have 2 declarative_base classes: Person and Inquiry. I have created a relationship in Inquiry with a backref to Person. When observing the an Inquiry object the person variable correctly points to Person, however when observing Person

[sqlalchemy] Re: Proper way to make a TypeDecorator around Enum?

2010-08-09 Thread Nikolaj
It makes sense to subclass the type directly if I'm not messing with result or bind values. This works: class StringEnum(types.Enum): def __init__(self, *args, **kwargs): super(StringEnum, self).__init__(*args, native_enum=False, **kwargs) self.length = 255 I'm still curious

[sqlalchemy] Re: backref list empy

2010-08-09 Thread zzer0
Hi I thank you very much for your help. I managed to figure out that my Inquiries table had no associated types in the actual sqlite database, so after I changed the person_id field to Numeric, all was well and done without changes to the code. Perhaps just to be aware of. As for the Adjacency

[sqlalchemy] Re: backref list empy

2010-08-09 Thread zzer0
Hi I thank you very much for your help. I managed to figure out that my Inquiries table had no associated types in the actual sqlite database, so after I changed the person_id field to Numeric, all was well and done without changes to the code. Perhaps just to be aware of. As for the Adjacency

Re: [sqlalchemy] Re: Proper way to make a TypeDecorator around Enum?

2010-08-09 Thread Michael Bayer
On Aug 9, 2010, at 10:32 AM, Nikolaj wrote: It makes sense to subclass the type directly if I'm not messing with result or bind values. This works: class StringEnum(types.Enum): def __init__(self, *args, **kwargs): super(StringEnum, self).__init__(*args, native_enum=False,

[sqlalchemy] Re: Proper way to make a TypeDecorator around Enum?

2010-08-09 Thread Nikolaj
On Aug 9, 3:38 pm, Michael Bayer mike...@zzzcomputing.com wrote: its pulling off the types.Enum callable from self.__class__ (which actually seems unnecessary here, self.impl should be fine), then calling that with the given arguments.  So it should be setting up the native_enum=False part

[sqlalchemy] Adding columns to SELECT clause without having to filter result entities

2010-08-09 Thread Nikolaj
I have an association object pattern between Person and Item through PersonItem. Item is subclassed using single-table inheritance into FooItem and BarItem, with a column named 'foo' on FooItem (although it's obviously on the same shared table as BarItem). I'd like to query PersonItem and

Re: [sqlalchemy] Adding columns to SELECT clause without having to filter result entities

2010-08-09 Thread Michael Bayer
On Aug 9, 2010, at 10:56 AM, Nikolaj wrote: I have an association object pattern between Person and Item through PersonItem. Item is subclassed using single-table inheritance into FooItem and BarItem, with a column named 'foo' on FooItem (although it's obviously on the same shared table as

[sqlalchemy] SQLAlchemy 0.6.4 Documentation: SQLite

2010-08-09 Thread BartonC
There's a broken link on http://www.sqlalchemy.org/docs/reference/dialects/sqlite.htm to the old pysqlite project: quoteFull documentation on pysqlite is available at: http://www.initd.org/pub/software/pysqlite/doc/usage-guide.html/quote. Can we get this update to link to:

Re: [sqlalchemy] SQLAlchemy 0.6.4 Documentation: SQLite

2010-08-09 Thread Michael Bayer
On Aug 9, 2010, at 1:00 PM, BartonC wrote: There's a broken link on http://www.sqlalchemy.org/docs/reference/dialects/sqlite.htm to the old pysqlite project: quoteFull documentation on pysqlite is available at: http://www.initd.org/pub/software/pysqlite/doc/usage-guide.html/quote. Can we

[sqlalchemy] Automatically merge a specific model/object

2010-08-09 Thread flzz
Greetings, I have an object model which I'm persisting with SQLAlchemy (0.6.3). I have a need for one of the objects in the model to always merge itself into the session when a new instance is added. For example, given sub = Subscription(email=EmailAddress(value='f...@bar.com)) which will

Re: [sqlalchemy] Automatically merge a specific model/object

2010-08-09 Thread Michael Bayer
On Aug 9, 2010, at 5:12 PM, flzz wrote: Greetings, I have an object model which I'm persisting with SQLAlchemy (0.6.3). I have a need for one of the objects in the model to always merge itself into the session when a new instance is added. For example, given sub =

[sqlalchemy] To select a few columns in some tables related

2010-08-09 Thread Alvaro Reinoso
Hello, I have these classes: class Channel(rdb.Model): rdb.metadata(metadata) rdb.tablename(channels) id = Column(id, Integer, primary_key=True) title = Column(title, String(100)) items = relationship(MediaItem, secondary=channel_items,

Re: [sqlalchemy] To select a few columns in some tables related

2010-08-09 Thread Michael Bayer
On Aug 9, 2010, at 6:26 PM, Alvaro Reinoso wrote: Hello, I have these classes: class Channel(rdb.Model): rdb.metadata(metadata) rdb.tablename(channels) id = Column(id, Integer, primary_key=True) title = Column(title, String(100)) items =

[sqlalchemy] isolation_level and psycopg2?

2010-08-09 Thread Jon Nelson
I tried setting isolation_level to SERIALIZABLE in my create_engine options, while using psycopg2. However, an strace clearly shows that it is using READ COMMITTED. Is setting the isolation_level not supported with psycopg2? -- See, when the GOVERNMENT spends money, it creates jobs; whereas

Re: [sqlalchemy] isolation_level and psycopg2?

2010-08-09 Thread Michael Bayer
On Aug 10, 2010, at 12:03 AM, Jon Nelson wrote: I tried setting isolation_level to SERIALIZABLE in my create_engine options, while using psycopg2. However, an strace clearly shows that it is using READ COMMITTED. Is setting the isolation_level not supported with psycopg2? Here's a test:

Re: [sqlalchemy] isolation_level and psycopg2?

2010-08-09 Thread Jon Nelson
On Mon, Aug 9, 2010 at 11:27 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 10, 2010, at 12:03 AM, Jon Nelson wrote: I tried setting isolation_level to SERIALIZABLE in my create_engine options, while using psycopg2. However, an strace clearly shows that it is using READ COMMITTED.