[sqlalchemy] Practical ways for dealing with concurrency problems?

2010-11-09 Thread Russell Warren
I've got several questions about dealing with concurrency issues in SQLAlchemy. To try and help with the asking, I'll use a small example similar to a situation I've got in an SQLAlchemy application. In this application, there is a table that tracks objects and their order/ position, something li

[sqlalchemy] Re: FlushError: Instance has NULL identity

2010-11-09 Thread Torsten Engelbrecht
> While the above code uses some patterns that are unnecessary, there's nothing > about it which would cause that error to occur.   To my knowledge, the only > way that particular condition arises is if a flush occurs at an inappropriate > time, namely within an object load, which does not seem

[sqlalchemy] Re: Multiple request in the same controller causing problems with SQLAlchemy Session object

2010-11-09 Thread Alan Castro
Hi guys, An update: Mike is right! The connector doesn't get along with child processes... For a quick setup and since I'm using uWSGI and Nginx, I just created a cluster o uwsgi connections and ran 3 independent process of my application. All my tests passed nicely. @Warwick I'm using mysql-pyth

Re: [sqlalchemy] Re: SELECT ARRAY(SELECT ...

2010-11-09 Thread Michael Hipp
On 11/9/2010 3:55 PM, Gunnlaugur Briem wrote: select([ func.ARRAY( select([t.c.value]) .where(t.c.id<3) .as_scalar() ) .label('array_col') ]) Thank you! That works swimmingly. I now know why my search didn't turn up anything as it is evidently one of those "If the func

Re: [sqlalchemy] (Newbie) Using a custom collection extending from a dict(). Is that doable?

2010-11-09 Thread Hector Blanco
Shoot!! It works!! :D :D -- Parent.py (extract) -- # . . . child1 = relationship( "Child", uselist=True, primaryjoin=lambda: and_((Parent.id == Child.parent_id), (Child.type == "VR")),

Re: [sqlalchemy] (Newbie) Using a custom collection extending from a dict(). Is that doable?

2010-11-09 Thread Michael Bayer
On Nov 8, 2010, at 6:36 PM, Hector Blanco wrote: > methods that I have implemented and that need to be there. That would > be the "ZepConnector" (and, for purposes of the example, it's method > foo() it's the one I need to use). As you can see in the following > lines, I randomly test its availab

[sqlalchemy] Multiple request in the same controller causing problems with SQLAlchemy Session object

2010-11-09 Thread Warwick Prince
Hi Alan We're also doing battle with this one.. One thing I did find was if I had large(ish) BLOB values, MySQL would go away. I found that I had to tweak some settings on MySQL to allow for larger sizes. (The default settings appear to be ridiculously small). Let me know what else you fi

Re: [sqlalchemy] Multiple request in the same controller causing problems with SQLAlchemy Session object

2010-11-09 Thread Michael Bayer
On Nov 9, 2010, at 4:56 PM, Alan Castro wrote: > Hello, > > Latelly I've been running into this issue: > > OperationalError: (OperationalError) (2013, 'Lost connection to MySQL > server during query') SELECT... > > To contextualize, I developed a Pylons application using > scoped_session (defa

[sqlalchemy] Multiple request in the same controller causing problems with SQLAlchemy Session object

2010-11-09 Thread Alan Castro
Hello, Latelly I've been running into this issue: OperationalError: (OperationalError) (2013, 'Lost connection to MySQL server during query') SELECT... To contextualize, I developed a Pylons application using scoped_session (default in pylons). And it was working until I created some extra proce

[sqlalchemy] Re: SELECT ARRAY(SELECT ...

2010-11-09 Thread Gunnlaugur Briem
This works: select([ func.ARRAY( select([t.c.value]) .where(t.c.id<3) .as_scalar() ) .label('array_col') ]) - Gulli On Nov 9, 3:43 pm, Michael Hipp wrote: > Can someone show me the gist of how to construct an SA query that > produces SQL* of the form > > SELECT ARRAY(SELECT

Re: [sqlalchemy] Re: sqla and firebird

2010-11-09 Thread Tamás Bajusz
On Tue, Nov 9, 2010 at 4:10 PM, Domingo Aguilera wrote: > Werner, > > I am using kinterbasdb downloaded just few days ago.  Also I am using > sqla 0.6.5 . > > I worked with  firebird rdbms engine several years ago but not from > python.  This is the first time I am using firebird from python and >

[sqlalchemy] SELECT ARRAY(SELECT ...

2010-11-09 Thread Michael Hipp
Can someone show me the gist of how to construct an SA query that produces SQL* of the form SELECT ARRAY(SELECT ... FROM ... WHERE ...) as array_col Thanks, Michael * http://www.postgresql.org/docs/8.4/interactive/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS -- You received this mess

Re: [sqlalchemy] no ALTER statements issued when using use_alter=True

2010-11-09 Thread Michael Bayer
On Nov 9, 2010, at 8:47 AM, yannick wrote: > The following simple code does not seem to produce the ALTER statement > expected for the Contact.ownername column. > When I look at the DB, there is no ForeignKeyConstraint on > Contact.ownername. SQLite doesn't support ALTER on an existing Column c

Re: [sqlalchemy] FlushError: Instance has NULL identity

2010-11-09 Thread Michael Bayer
On Nov 9, 2010, at 3:44 AM, Torsten Engelbrecht wrote: > Hi, > > I need to use dynamic table names in a project (though for the same > object). Now I got the following problem: > - I fetch data from an RSS feed to fill my database. Its an RSS feed > with many pages, each page has around 100 item

Re: [sqlalchemy] Does SQLAlchemy support read-write splitting?

2010-11-09 Thread Michael Bayer
this is usually called a "read slave" and you do it by either switching the "bind" used in your Session, or by using two different sessions.In a web application I'll typically build a decorator for controllers that performs this switch transparently: @uses_master def my_controller_method(se

[sqlalchemy] no ALTER statements issued when using use_alter=True

2010-11-09 Thread yannick
The following simple code does not seem to produce the ALTER statement expected for the Contact.ownername column. When I look at the DB, there is no ForeignKeyConstraint on Contact.ownername. I think this results in problems later on: when I activate the relationships, I cannot do v=User(username=

[sqlalchemy] Re: sqla and firebird

2010-11-09 Thread Domingo Aguilera
Werner, I am using kinterbasdb downloaded just few days ago. Also I am using sqla 0.6.5 . I worked with firebird rdbms engine several years ago but not from python. This is the first time I am using firebird from python and from sqlalchemy ( been using python since 2004 ). I have an app in w

[sqlalchemy] Re: FlushError: Instance has NULL identity

2010-11-09 Thread Torsten Engelbrecht
Sorry for the double thread. I was waiting for it to show up for hours. Please remove one of them. Thanks On Nov 9, 4:44 pm, Torsten Engelbrecht wrote: > Hi, > > I need to use dynamic table names in a project (though for the same > object). Now I got the following problem: > - I fetch data from a

[sqlalchemy] FlushError: Instance has NULL identity

2010-11-09 Thread Torsten Engelbrecht
Hi, I need to use dynamic table names in a project (though for the same object). Now I got the following problem: - I fetch data from an RSS feed to fill my database. Its an RSS feed with many pages, each page has around 100 items - I fetch the first page and create a table + mapper for a dynamic

[sqlalchemy] FlushError (Instance has a NULL identity key) for dynamicaly created tables

2010-11-09 Thread Torsten Engelbrecht
Hi, I need to use dynamic table names in a project (though for the same object). Now I got the following problem: - I fetch data from an RSS feed to fill my database. Its an RSS feed with many pages, each page has around 100 items - I fetch the first page and create a table + mapper for a dynamic

[sqlalchemy] Re: 'list' object has no attribute '_state'

2010-11-09 Thread pianoman
Hi, Michael Thanks so much for your feedback. You were right on the button (second scenario): I was pretty sure I was passing a scalar to the list's append() method but was, in fact, passing it another list. Help greatly appreciated, really. Regards On Nov 6, 2:58 pm, Michael Bayer wrote: > On

Re: [sqlalchemy] sqla and firebird

2010-11-09 Thread werner
On 09/11/2010 01:34, Michael Bayer wrote: not sure if anyone knows. I have 2.1 running here for my own tests. On Nov 8, 2010, at 5:05 PM, Domingo Aguilera wrote: Is firebird 2.5 working with sqla. ? I am in the midst of moving to FB 2.5 and SA 0.6.5 and have not encountered any problems y