1

I've got a database created using Django models which I'm now accessing using SQLAlchemy and Elixir. The querying works and I can pull items out of the database perfectly happily but when I edit them and try to save them it throws the following exception:

>>> p = Problem.query.first()
>>> p
<Problem('Test Problem', 'This is a test problem so the database has something in it', 'SBMT')>
>>> p.name
u'Test Problem'
>>> p.name = "Test_Problem"
>>> p.save()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/elixir/entity.py", line 1116, in save
    return self._global_session.save(self, *args, **kwargs)
    AttributeError: 'Session' object has no attribute 'save'

What am I doing wrong? Have I missed a crucial part of the set up that is preventing me from saving things to the database or is it a problem with my versions of elixir and SQLAlchemy?

I've already run setup_all() and the metadata.bind is all set, hence I can query the database.

Ben
  • 51,770
  • 36
  • 127
  • 149
Haegin
  • 530
  • 3
  • 11

1 Answers1

0

I'm no Elixir expert, but from the documentation it looks like it uses something called a global session.

To save the changes to the database, you do a session.commit(), there's no save() method like in Django.

Uku Loskit
  • 40,868
  • 9
  • 92
  • 93
  • 1
    Thanks! I'm not sure how I missed that. Somehow I ended up trawling through blog posts and old questions on here involving .save() that never seemed to get anywhere. – Haegin Jul 07 '11 at 11:16