Re: [sqlalchemy] dialect sensible declaration

2012-07-09 Thread alex bodnaru
hello michael, friends, after successfuly fixing the ddl by the append_constraint event, the relations that needed the said foreign keys remained orphan, asking for a foreign_keys argument and failing to load the remote table: class Lang(DeclarativeBase): lang_code = Column(String(20),

[sqlalchemy] echo_pool=True doesn't seem to have an effect

2012-07-09 Thread bojanb
Hi, I'm trying to debug some issues with sessions in my SQLAlchemy 0.7.4 application. However, setting echo_pool to True doesn't seem to log anything to standard output: db_engine=create_engine(DB_URI, echo_pool=True) Session = sessionmaker(bind=db_engine) Standard logging (echo=True) works

Re: [sqlalchemy] dialect sensible declaration

2012-07-09 Thread Michael Bayer
On Jul 9, 2012, at 4:48 AM, alex bodnaru wrote: hello michael, friends, after successfuly fixing the ddl by the append_constraint event, the relations that needed the said foreign keys remained orphan, asking for a foreign_keys argument and failing to load the remote table: class

Re: [sqlalchemy] Dialect-specific UserDefinedType variants

2012-07-09 Thread Michael Bayer
with_variant() is a straightforward way to go, you just give any existing type the per-dialect variants you want: mytype = MyHstoreType.with_variant(MyPGHstore, postgresql) if you were using TypeDecorator, you could also add this in using the load_dialect_impl() method. That's the end effect

Re: [sqlalchemy] echo_pool=True doesn't seem to have an effect

2012-07-09 Thread Michael Bayer
don't feel bad because I had to spend 10 minutes figuring this out again, to see checkin/checkout events you need to use echo_pool=debug. echo_pool=True just shows major events like connection invalidations. On Jul 9, 2012, at 9:25 AM, bojanb wrote: Hi, I'm trying to debug some issues

[sqlalchemy] Custom column + AttributeExtension -- Value parameter empty in set() method of the Extension

2012-07-09 Thread Hector Blanco
Hello everyone. I have a class that uses a custom column to store a list of strings. The column is saved in the database using a comma sepparated string. When it's loaded into an instance, it becomes a list: class Keyword(declarativeBase): __tablename__ = keywords _id =

Re: [sqlalchemy] echo_pool=True doesn't seem to have an effect

2012-07-09 Thread bojanb
Thanks. Now I'm able to confirm that connections are being returned to the pool. On Monday, July 9, 2012 3:50:53 PM UTC+2, Michael Bayer wrote: don't feel bad because I had to spend 10 minutes figuring this out again, to see checkin/checkout events you need to use echo_pool=debug.

Re: [sqlalchemy] Dialect-specific UserDefinedType variants

2012-07-09 Thread Jon Parise
Thanks for the advice. I pursued the TypeDecorator path, and I'm relatively happy with something along these lines: class HStoreType(UserDefinedType): PostgreSQL-specific ``hstore`` storage type. python_type = dict def get_col_spec(self): return 'hstore' class

[sqlalchemy] Problem with Association Object mapping

2012-07-09 Thread Jules Stevenson
Hi All, I'm trying to put together an Association Object mapping within a pylons app, but am getting the following error: OperationalError: (OperationalError) (1364, Field 'user_id' doesn't have a default value) 'INSERT INTO contact_duedate_user_association (contact_id, modded) VALUES (%s, %s)'

[sqlalchemy] Aliasing a constant within a recursive CTE

2012-07-09 Thread Russ
I'm trying to use the new CTE support in SQLAlchemy in a way that will allow me to reference the recursion level as a field in the query result. This is easy in a straight SQL CTE by aliasing a constant in the non-recursive part, and then referencing the alias in the recursive part. The limited

Re: [sqlalchemy] Aliasing a constant within a recursive CTE

2012-07-09 Thread Ryan Kelly
On Mon, Jul 09, 2012 at 03:12:16PM -0700, Russ wrote: I'm trying to use the new CTE support in SQLAlchemy in a way that will allow me to reference the recursion level as a field in the query result. This is easy in a straight SQL CTE by aliasing a constant in the non-recursive part, and then

Re: [sqlalchemy] Problem with Association Object mapping

2012-07-09 Thread Michael Bayer
On Jul 9, 2012, at 6:08 PM, Jules Stevenson wrote: Hi All, I'm trying to put together an Association Object mapping within a pylons app, but am getting the following error: OperationalError: (OperationalError) (1364, Field 'user_id' doesn't have a default value) 'INSERT INTO

Re: [sqlalchemy] Custom column + AttributeExtension -- Value parameter empty in set() method of the Extension

2012-07-09 Thread Michael Bayer
On Jul 9, 2012, at 12:38 PM, Hector Blanco wrote: Hello everyone. I have a class that uses a custom column to store a list of strings. The column is saved in the database using a comma sepparated string. When it's loaded into an instance, it becomes a list: class

[sqlalchemy] Re: Aliasing a constant within a recursive CTE

2012-07-09 Thread Russ
select(literal(0).alias(x)) should do it, see the documentation at ... Thanks... literal() gave me a location on which to attach a label I can reference. I'm closer, but still can't get this to work. Here's my closest so far (iwth SQLAlchemy 0.7.8): import sqlalchemy as sa #set up the

Re: [sqlalchemy] Re: Aliasing a constant within a recursive CTE

2012-07-09 Thread Michael Bayer
First off, there's a bug with CTE + union in 0.7.8 and earlier. Get 0.7.9 from the hg tip linked on the download page. Next, maybe try calling cte() *after* you've done select(...).union_all(otherselect()). Not sure if that will do it though. On Jul 9, 2012, at 9:41 PM, Russ wrote:

Re: [sqlalchemy] Re: Aliasing a constant within a recursive CTE

2012-07-09 Thread Russell Warren
On Mon, Jul 9, 2012 at 9:53 PM, Michael Bayer mike...@zzzcomputing.comwrote: First off, there's a bug with CTE + union in 0.7.8 and earlier. Get 0.7.9 from the hg tip linked on the download page. Next, maybe try calling cte() *after* you've done select(...).union_all(otherselect()). Not