[sqlalchemy] using scoped_session in serial mode as well as parallel (multi-threaded) mode

2010-08-12 Thread Faheem Mitha
Hi, I'm using scoped_session with PostgreSQL to run multiple threads, each thread creating a table. However, I'm getting some pretty weird and inconsistent errors (segfaults from Python with some very peculiar errors), and I was wondering if my usage was at fault. The program has a serial

[sqlalchemy] mixed up relationships

2010-08-12 Thread Bleve
I'm using SQLAlchemy 0.6.3 on Python 2.6 (win32) I have a class, Efforts, which has many splits (time and distance and some other fluff), so for each training effort, there can be one or more splits. It has a few other relationships as well, but this is the important one, or at least, the one

[sqlalchemy] Re: using scoped_session in serial mode as well as parallel (multi-threaded) mode

2010-08-12 Thread Faheem Mitha
Addendum: the types of error I'm seeing includes SQLA trying to execute notices from the PG server eg. one of the tracebacks I'm seeing is: #0 PyObject_Malloc (nbytes=86) at ../Objects/obmalloc.c:756 #1 0x00455eb5 in PyString_FromString (str=0x2de0ece0 WARNING: there is no

[sqlalchemy] Multiple Sessions

2010-08-12 Thread Erich Eder
I've found a strange behaviour when using multiple sessions: A committed change to an object in one session does not get reflected in the other session, even after a session.expire_all() (or expire() or refresh() on the object. In fact, even an explicit query does not retrieve the changed data.

[sqlalchemy] Re: mixed up relationships

2010-08-12 Thread Sven A. Schmidt
Carl, the formatting got a bit messed up but if I read your definition correctly you defined the relation as 'splits'. So you'd want to write trainingEffor.splits (lower case 's' in splits). -sas On Aug 12, 9:20 am, Bleve carl.i.bre...@gmail.com wrote: I'm using SQLAlchemy 0.6.3 on Python 2.6

[sqlalchemy] Re: using scoped_session in serial mode as well as parallel (multi-threaded) mode

2010-08-12 Thread Faheem Mitha
Another reply to my own message, sorry. Another thing I might be doing wrong is my usage of MetaData. The code I have looks like db = create_engine(self.dbstring) meta = self.table_dict['metadata'] meta.bind = db meta.create_all() Session = scoped_session(sessionmaker())

Re: [sqlalchemy] Multiple Sessions

2010-08-12 Thread Michael Bayer
On Aug 12, 2010, at 7:36 AM, Erich Eder wrote: I've found a strange behaviour when using multiple sessions: A committed change to an object in one session does not get reflected in the other session, even after a session.expire_all() (or expire() or refresh() on the object. In fact, even an

Re: [sqlalchemy] Re: mixed up relationships

2010-08-12 Thread Carl Brewer
On 12/08/2010 10:03 PM, Sven A. Schmidt wrote: Carl, the formatting got a bit messed up but if I read your definition correctly you defined the relation as 'splits'. So you'd want to write trainingEffor.splits (lower case 's' in splits). heh! Case sensitivity bites! Thank you Carl --

Re: [sqlalchemy] using scoped_session in serial mode as well as parallel (multi-threaded) mode

2010-08-12 Thread Michael Bayer
On Aug 12, 2010, at 5:10 AM, Faheem Mitha wrote: Hi, I'm using scoped_session with PostgreSQL to run multiple threads, each thread creating a table. Its generally a poor application practice for an application to need new permanent tables on the fly. I think reddit's application

[sqlalchemy] Re: using scoped_session in serial mode as well as parallel (multi-threaded) mode

2010-08-12 Thread Faheem Mitha
On Thu, 12 Aug 2010 08:47:33 -0400, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 12, 2010, at 5:10 AM, Faheem Mitha wrote: Hi, I'm using scoped_session with PostgreSQL to run multiple threads, each thread creating a table. Its generally a poor application practice for an

Re: [sqlalchemy] Re: using scoped_session in serial mode as well as parallel (multi-threaded) mode

2010-08-12 Thread Michael Bayer
On Aug 12, 2010, at 9:25 AM, Faheem Mitha wrote: Hi Mike, Thanks for the response, but I don't follow. When you say multiple threads are hitting the session you have above, which session are you referring to? There is more than one object above that could be called a session. Ie. I

[sqlalchemy] Re: using scoped_session in serial mode as well as parallel (multi-threaded) mode

2010-08-12 Thread Faheem Mitha
On Thu, 12 Aug 2010 09:44:04 -0400, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 12, 2010, at 9:25 AM, Faheem Mitha wrote: Hi Mike, Thanks for the response, but I don't follow. When you say multiple threads are hitting the session you have above, which session are you

[sqlalchemy] Re: using scoped_session in serial mode as well as parallel (multi-threaded) mode

2010-08-12 Thread Faheem Mitha
On Thu, 12 Aug 2010 09:44:04 -0400, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 12, 2010, at 9:25 AM, Faheem Mitha wrote: Hi Mike, Thanks for the response, but I don't follow. When you say multiple threads are hitting the session you have above, which session are you

Re: [sqlalchemy] Re: using scoped_session in serial mode as well as parallel (multi-threaded) mode

2010-08-12 Thread Michael Bayer
On Aug 12, 2010, at 11:47 AM, Faheem Mitha wrote: On Thu, 12 Aug 2010 09:44:04 -0400, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 12, 2010, at 9:25 AM, Faheem Mitha wrote: Hi Mike, Thanks for the response, but I don't follow. When you say multiple threads are hitting

[sqlalchemy] Re: User DataType for casting

2010-08-12 Thread Kent
On Jul 30, 7:25 am, Kent k...@retailarchitects.com wrote: Also, I'm afraid the CAST(NULL AS VARCHAR(255)) doesn't work with Oracle 8, but I don't have access to Oracle 8 at the moment.  I'm afraid you need TO_NUMBER(NULL) or TO_CHAR(NULL), etc... I'm wrong, CAST seems to work fine on Oracle

[sqlalchemy] How to link one table to itself?

2010-08-12 Thread Alvaro Reinoso
Hello, I'm trying to link one table to itself. I have media groups which can contain more media group. I created a relation many to many: media_group_groups = Table( media_group_groups, metadata, Column(groupA_id,

[sqlalchemy] Re: using scoped_session in serial mode as well as parallel (multi-threaded) mode

2010-08-12 Thread Faheem Mitha
[This message has also been posted.] On Thu, 12 Aug 2010 12:47:37 -0400, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 12, 2010, at 11:47 AM, Faheem Mitha wrote: On Thu, 12 Aug 2010 09:44:04 -0400, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 12, 2010, at 9:25 AM, Faheem

Re: [sqlalchemy] Re: using scoped_session in serial mode as well as parallel (multi-threaded) mode

2010-08-12 Thread Michael Bayer
On Aug 12, 2010, at 2:41 PM, Faheem Mitha wrote: objects among threads, they reference their owning session in order to load additional state. If you pass objects between threads you should merge() them into the current thread's session first, then use that result. I see. That's very

[sqlalchemy] Re: How to link one table to itself?

2010-08-12 Thread Alvaro Reinoso
I'm still working on the solution. I've found out some stuff in internet. I guess I'm close to, but I haven't got it yet. I'm using this for the relation: mediaGroups = relationship(MediaGroup, secondary=media_group_groups, order_by=MediaGroup.title, backref='media_groups', foreign_keys =

Re: [sqlalchemy] Re: How to link one table to itself?

2010-08-12 Thread Michael Bayer
On Aug 12, 2010, at 5:09 PM, Michael Bayer wrote: On Aug 12, 2010, at 4:58 PM, Alvaro Reinoso wrote: I'm still working on the solution. I've found out some stuff in internet. I guess I'm close to, but I haven't got it yet. I'm using this for the relation: mediaGroups =

[sqlalchemy] Extending and automating the vertical dictionary paradigm

2010-08-12 Thread Choy
Hi all -- I am relatively new to sqlalchemy and am in the midst of building a generic vertical dictionary collection base class that can be subclassed and extended in different ways. I began by examining the dictlike.py and dictlike-polymorphic SQLalchemy examples and extended them into a class

[sqlalchemy] Re: How to link one table to itself?

2010-08-12 Thread Alvaro Reinoso
I'm trying that, but I got different error: Could not determine relationship direction for primaryjoin condition 'users.id = :id_1', on relationship User.mediaGroups. Specify the 'foreign_keys' argument to indicate which columns on the relationship are foreign. As I can see, the error is related

[sqlalchemy] Specifying additional primaryjoin conditions for bidirectional adjacency list relationship

2010-08-12 Thread Nikolaj
Hi there, I'm exploring the bidirectional adjacency list pattern described in the documentation (the scalar relationship is intentional): Person.child = relationship( Person, uselist=False, backref=backref('parent', remote_side=Person.id) ) However, I'd like to add an additional

[sqlalchemy] Re: Multiple Sessions

2010-08-12 Thread Erich Eder
Thanks for pointing me there, Michael. Wasn't aware of that InnoDB feature. Make all sense, now. On Aug 13, 12:37 am, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 12, 2010, at 7:36 AM, Erich Eder wrote: I've found a strange behaviour when using multiple sessions: A committed change