On Mon, Dec 8, 2008 at 01:32, CostaRica <[EMAIL PROTECTED]> wrote:
> from model import *
> setup_all()
> sa = SociedadAnonima(nombre=u"Optica X",cedula=u"3-101-123456")
> session.commit()
>
> Error I get
> ------------
> /usr/bin/python -u "/home/edgar/createData.py"
> Traceback (most recent call last):
> File "/home/edgar/createData.py", line 7, in <module>
> session.commit()
> File "/var/lib/python-support/python2.5/sqlalchemy/orm/scoping.py",
> line 98, in do
> return getattr(self.registry(), name)(*args, **kwargs)
> File "/var/lib/python-support/python2.5/sqlalchemy/orm/session.py",
> line 552, in commit
> raise exceptions.InvalidRequestError("No transaction is begun.")
> sqlalchemy.exceptions.InvalidRequestError: No transaction is begun.
>
>
> I see that "No transaction is begun" is the problem, but -How do I
> begin a transaction?
session.begin()
I'm guessing you are using Elixir 0.5.x, and using its default
session. If this is indeed your case, you *might* want to use
session.flush() instead of session.commit(), because in 0.5.x, the
session is "autoflush=False", "autocommit=True". See
http://www.sqlalchemy.org/docs/05/session.html for some details.
--
Gaƫtan de Menten
http://openhex.org
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---