my problem was solved using Postgres.. :S (I was using sqlite that doesn't
support this..)

i just do:

upd = MyClass.query.with_lockmode("update").one()
upd.somenumber += 10
session.commit()

and the lock works only for that class that's updated.

I sugest you to try doing this way and be sure that this feature is enabled
in postgres.

Cheers :)

2009/9/21 Michael <[email protected]>

>
> Hello,
>
> I am having the exact same problem (in case it matters: I am using
> postgres).  Has anyone figured out how to do this?
>
> Cheers,
>
> Michael
>
>
> On Aug 26, 11:23 pm, Felipe Ronchi Brigido <[email protected]> wrote:
> > Hi !
> > I am pretty new to elixir..
> > So.. how can i lock some rows while updating them.
> >
> > I've tried to do:
> >
> > session.begin()
> > upd = MyClass.query().with_lockmode("update").one()
> > upd.somenumber += 10
> > session.commit()
> >
> > but not successful. calling to session.begin() raise:
> >
> > sqlalchemy.exc.InvalidRequestError: A transaction is already begun.
> > Use subtransactions=True to allow subtransactions.
> >
> > and doing only:
> >
> > upd = MyClass.query().with_lockmode("update").one()
> > upd.somenumber += 10
> > session.commit()
> >
> > he doesn't lock.
> >
> > what am i doing wrong? :S
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to