[sqlalchemy] improving connection resiliency

2007-02-08 Thread Rick S.
I am trying to build some resiliency into our API. The consumers are our internal python scripts. The backend has sqlalchemy 0.2.8, psycopg2, and a postgresql 8.1.6 database. I am wondering if there isn't a better way to handle connection issues than how I am doing it (see the sample below)? One

[sqlalchemy] Re: sequences skipping and reporting incorrectly

2006-12-01 Thread Rick S.
Thank you much! You hit the nail on the head with your observation about the bldcmdid not being a primary key. I verified that an identical operation worked 100% correctly on a table where the primary key was also a serial type. I needed the combination of a few keys to be unique. I naively used

[sqlalchemy] Re: sequences skipping and reporting incorrectly

2006-12-01 Thread Rick S.
I don't need to do anything between. Our use of transactions is simple-- almost always a single-operation happens per flush. I looked at after_insert, but am not exactly sure how that can help me. Do I need to define something so that it retrieves the record from the database? (I looked for docu

[sqlalchemy] Re: sequences skipping and reporting incorrectly

2006-12-01 Thread Rick S.
>From the postgresql documentation: CREATE TABLE tablename ( colname SERIAL ); is equivalent to specifying: CREATE SEQUENCE tablename_colname_seq; CREATE TABLE tablename ( colname integer DEFAULT nextval('tablename_colname_seq') NOT NULL ); And, postgresql regarding default values:

[sqlalchemy] sequences skipping and reporting incorrectly

2006-12-01 Thread Rick S.
I am having two problems when using sequences in SA .28 with postgresql 8.1. 1) The sequence is skipping a number. 2) Retrieval of newly created records fail until a disconnect/connect to the database. In my test case, the last serial used was 14. When I saved a record, it was reported that t

[sqlalchemy] Re: how to disconnect when using global_connect?

2006-11-17 Thread Rick S.
Thanks for the advice. I think I'm now doing things the way you prescribe. Below is the some skeletal code. Not sure if anyone else will find it useful. Note that this is simple, single-threaded and in a controlled environment (I'm making excuses for the global variables...) Other code can refer

[sqlalchemy] Re: how to disconnect when using global_connect?

2006-11-16 Thread Rick S.
I suspected that there was a global engine instance that I could call the dispose() method against. But I looked for it in my debugger and I looked in the documentation and cannot identify it. That's really been the crux of my problem. On a whim, I tried: foo = global_connect(...) But global_co

[sqlalchemy] how to disconnect when using global_connect?

2006-11-16 Thread Rick S.
I feel more comfortable doing certain things explicitly--like closing a client session. I am thinking that doing so may also get rid of the following annoying messages at the db server: LOG: could not receive data from client: Connection reset by peer LOG: unexpected EOF on client connection I

[sqlalchemy] Re: no op updates using a self-referential relationship

2006-10-25 Thread Rick S.
Thanks! for all the work you are doing on this. It is a really great implementation as it is now. The updates you have provided about future features is even more encouraging. ORM is a tough nut to crack! Rick --~--~-~--~~~---~--~~ You received this message beca

[sqlalchemy] Re: no op updates using a self-referential relationship

2006-10-25 Thread Rick S.
Thanks!, Michael. That did work. When I solved one problem I created another. I guess it didn't help that I did not heed the warning to be careful about explict flushes. Not sure if this makes any sense but here is what I was trying to do: # mypythonscript.py import myobjects # myobjects is my

[sqlalchemy] no op updates using a self-referential relationship

2006-10-25 Thread Rick S.
I added two properties to a mapper. One of the properties is from an external table and the other is self-referential. If I update the external property, SA picks up on the change. A save and flush operation works fine. However, when I modify and subsequently save/flush the self-referential proper

[sqlalchemy] Re: how to pass dynamic parameters to query.select_by

2006-10-16 Thread Rick S.
Thanks! I feel a bit silly. That was pretty basic. I noticed in the examples in the documents that the *arg's used implicit column names and the **kargs used the explicit tablename.c.col_name syntax. 20/20 hindsight. I turned a coincidence into a pattern. Oops. Again, thanks for the fast answer.

[sqlalchemy] how to pass dynamic parameters to query.select_by

2006-10-16 Thread Rick S.
I want to be able to dynamically generate selection contraints. However, at the final step where I pass a generated parameter list to the select-by() statement, I am getting errors. Any suggestions would be appreciated. This works fine: ormHostList = query.select_by(osplatform = 'win32', osna

[sqlalchemy] automatic determination of INSERT vs. UPDATE?

2006-10-13 Thread Rick S.
I'm not sure if I just haven't figured out how to map objects correctly yet, or if I am trying to automate something that cannot be automated in SA. I've played with mapping options, like relations, backref's, and cascade options. I can't seem to achieve automation with my objects in the way I wo