[sqlalchemy] Re: how to role back a delete from the session.

2008-02-08 Thread Mike Bernson
Michael Bayer wrote: > On Feb 8, 2008, at 1:06 PM, Mike Bernson wrote: > > >> I have a case where a delete was requested and on the commit to the >> transaction the delete fails with a >> integrity error. Problem is a foreign key constraint will not let >> the record be delete. Now I have a

[sqlalchemy] Re: how to role back a delete from the session.

2008-02-08 Thread Michael Bayer
On Feb 8, 2008, at 1:06 PM, Mike Bernson wrote: > > I have a case where a delete was requested and on the commit to the > transaction the delete fails with a > integrity error. Problem is a foreign key constraint will not let > the record be delete. Now I have a > session which tries to dele

[sqlalchemy] Re: Polymorphic and inheritance with missing children

2008-02-08 Thread Michael Bayer
On Feb 8, 2008, at 3:49 PM, Richard Levasseur wrote: > > Hm, we could do that, but that means that we have to outerjoin to > ~15 other tables. The primary table has ~200+ columns on it, each > child table has 10-20 columns, there are over a million records, and > our base filter criteria

[sqlalchemy] Re: Polymorphic and inheritance with missing children

2008-02-08 Thread Richard Levasseur
On Feb 8, 2008 11:27 AM, Michael Bayer <[EMAIL PROTECTED]> wrote: > > On Feb 8, 2008, at 2:01 PM, Richard Levasseur wrote: > > Ok, so I'm talking about 2 slightly different things at once: One is that > sqlalchemy doesn't call the mapper extensions when loading the data from the > inherited table

[sqlalchemy] Re: InvalidRequestError

2008-02-08 Thread Paul Johnston
Hi, >I do a session.clear(), all time, after of >session.save_or_update([obj]) >Can this be the problem? > > That is almost certainly your problem. Try removing the session.clear() and see if it then works. >When is advisable do a session.clear() ? > > When you're done with a batch of proce

[sqlalchemy] Re: Polymorphic and inheritance with missing children

2008-02-08 Thread Michael Bayer
On Feb 8, 2008, at 2:01 PM, Richard Levasseur wrote: > Ok, so I'm talking about 2 slightly different things at once: One > is that sqlalchemy doesn't call the mapper extensions when loading > the data from the inherited tables. The second is that it can't > load instances unless a record

[sqlalchemy] Newbie question: sAsync maintained? In use?

2008-02-08 Thread Dwig
'm just getting started with SA, and I'll want to be using it in a "back-end" server with an existing mssql database. I'm considering using Twisted as the basis for the server, and I've looked a bit into using sAsync. I've had trouble getting the Twisted XML-RPC Server Example to run, and that l

[sqlalchemy] Re: Polymorphic and inheritance with missing children

2008-02-08 Thread Richard Levasseur
On Feb 8, 2008 7:04 AM, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > On Feb 7, 2008, at 9:28 PM, Richard Levasseur wrote: > > > > > Ok, so I've been looking into getting it to work when the child record > > doesn't exist. I haven't had much luck. > > > > I wrote a stub mapper extension for tran

[sqlalchemy] how to role back a delete from the session.

2008-02-08 Thread Mike Bernson
I have a case where a delete was requested and on the commit to the transaction the delete fails with a integrity error. Problem is a foreign key constraint will not let the record be delete. Now I have a session which tries to delete this record any time I flush things. I have rolled back the

[sqlalchemy] InvalidRequestError

2008-02-08 Thread maxi
What means this error ? InvalidRequestError: Parent instance is not bound to a Session, and no contextual session is established; lazy load operation of attribute 'planilla' cannot proceed Note: CbteDet object mapper have a "planilla" relation attribute. (one to one relationship) I do a sessi

[sqlalchemy] Re: Object state change tracking

2008-02-08 Thread Michael Bayer
On Feb 8, 2008, at 5:50 AM, klaus wrote: > > Well, we are using SQLAlchemy in a multi-threaded environment. It is > integrated into Zope by means of z3c.sqlalchemy. All sessions should > be cleared before they are discarded. > > There are no exotic types involved. > > We have no useful profile o

[sqlalchemy] Re: Polymorphic and inheritance with missing children

2008-02-08 Thread Michael Bayer
On Feb 7, 2008, at 9:28 PM, Richard Levasseur wrote: > > Ok, so I've been looking into getting it to work when the child record > doesn't exist. I haven't had much luck. > > I wrote a stub mapper extension for translate_row and > populate_instance, but it doesn't seem to be called when it goes

[sqlalchemy] Re: Search in object list by field value

2008-02-08 Thread King Simon-NFHD78
> -Original Message- > From: sqlalchemy@googlegroups.com > [mailto:[EMAIL PROTECTED] On Behalf Of maxi > Sent: 08 February 2008 14:30 > To: sqlalchemy > Subject: [sqlalchemy] Re: Search in object list by field value > > > Thanks Simon, > I was doing of that manner. > > Now, is advisabl

[sqlalchemy] Re: Search in object list by field value

2008-02-08 Thread maxi
Thanks Simon, I was doing of that manner. Now, is advisable implement my own custom collection ? (One what implement a "locate" method for example) I was reading Custom Collection Implementations on sqlalchemy doc, but I'am not very clear over how implement this. Any help with this? Regards.

[sqlalchemy] Re: building mappers for an existing database

2008-02-08 Thread svilen
On Friday 08 February 2008 16:09:28 Chris Withers wrote: > Hi All, > > Almost similar to my last question, how do you go about building > mappers for an existing database schema? > > What happens if you don't get it quite right? :-S > > cheers, > > Chris search the group for things related to mig

[sqlalchemy] Re: schema changes

2008-02-08 Thread Paul Johnston
Hi Chris, What happens when the schema expected by the mappers doesn't match up to > the schema in the database? If the SQLAlchemy table definitions don't match the database, you will usually get SQL errors when you try to use them. The TurboGears admin tool can tell you the differences between

[sqlalchemy] building mappers for an existing database

2008-02-08 Thread Chris Withers
Hi All, Almost similar to my last question, how do you go about building mappers for an existing database schema? What happens if you don't get it quite right? :-S cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk --~--~---

[sqlalchemy] schema changes

2008-02-08 Thread Chris Withers
Hi All, What happens when the schema expected by the mappers doesn't match up to the schema in the database? I'm particularly thinking about what happens when you want to upgrade a piece of software that uses SA for it's data layer, and you want to change the schema... How have people tackle

[sqlalchemy] Re: Search in object list by field value

2008-02-08 Thread King Simon-NFHD78
> -Original Message- > From: sqlalchemy@googlegroups.com > [mailto:[EMAIL PROTECTED] On Behalf Of maxi > Sent: 08 February 2008 13:47 > To: sqlalchemy > Subject: [sqlalchemy] Re: Search in object list by field value > > > On 8 feb, 09:58, svilen <[EMAIL PROTECTED]> wrote: > > On Friday

[sqlalchemy] Re: Search in object list by field value

2008-02-08 Thread maxi
On 8 feb, 09:58, svilen <[EMAIL PROTECTED]> wrote: > On Friday 08 February 2008 14:26:04 maxi wrote: > a) let SQl do it > p1 = session.query(Person).filter_by(id==123).first() > #see .filter_by syntax Yes, of course, I know it. But my question appoint to how search in an object list. > b) get

[sqlalchemy] Re: Search in object list by field value

2008-02-08 Thread svilen
On Friday 08 February 2008 14:26:04 maxi wrote: a) let SQl do it p1 = session.query(Person).filter_by(id==123).first() #see .filter_by syntax b) get all people, then plain python: for p in people: if p.id == 123: break else: p=None --~--~-~--~~~---~--~~ You

[sqlalchemy] Search in object list by field value

2008-02-08 Thread maxi
Hi, Sorry if my question is not full sqlalchemy related. How can I find in an object list, a particular object, by his field value ? i.e.: class Person(object) def __init__(self, id, name): self.id = id self.name = name # Get a person object list people = session.query

[sqlalchemy] Re: Object state change tracking

2008-02-08 Thread klaus
Well, we are using SQLAlchemy in a multi-threaded environment. It is integrated into Zope by means of z3c.sqlalchemy. All sessions should be cleared before they are discarded. There are no exotic types involved. We have no useful profile output. The info is provided by the request monitor. Calls