Just open the ./elixir/entity.py, find the import line like this:
from sqlalchemy.orm import ScopedSession, \
then adjust it to:
from sqlalchemy.orm import scoped_session as ScopedSession, \
Question
I'm starting with Elixir and SQL Alchemy. I've created a python file connecting with a Mysql database to but as soon as I execute with python I get the error bellow:
root@raspberrypi:/Python/mainFlask/yonkiPOPS# python yonki.py
Traceback (most recent call last):
File "yonki.py", line 1, in <module>
from elixir import metadata, Entity, Field
File "/usr/local/lib/python2.7/dist-packages/Elixir-0.7.1-py2.7.egg/elixir/__init__.py", line 29, in <module>
from elixir.entity import Entity, EntityBase, EntityMeta, EntityDescriptor, \
File "/usr/local/lib/python2.7/dist-packages/Elixir-0.7.1-py2.7.egg/elixir/entity.py", line 17, in <module>
from sqlalchemy.orm import MapperExtension, mapper, object_session, \
ImportError: cannot import name ScopedSession
I have been looking for it but I don't find the reason. This is the yonki.py file:
from elixir import metadata, Entity, Field
from elixir import Unicode, UnicodeText
from elixir import *
class User(Entity):
username = Field(String(64))
metadata.bind = 'mysql://root:nomasandroid42@localhost/yonkiPOPS'
session.bind.echo = True
setup_all()
create_all()
I think that it's maybe due to a required module not installed but I don't know which one.
Solution 2
Just open the ./elixir/entity.py, find the import line like this:
from sqlalchemy.orm import ScopedSession, \
then adjust it to:
from sqlalchemy.orm import scoped_session as ScopedSession, \
OTHER TIPS
Elixir 0.7.1 seems to be incompatible with the latest version of SQLalchemy, 0.8. You can solve that problem with
sudo pip install SQLAlchemy==0.7.8
seems like sqlalchemy 0.8 changed the location of ScopedSession
If you wan't to still be able to update your libraries from the repositories, or don't have root access to change the file, just use this in your file:
import sqlalchemy.orm
sqlalchemy.orm.ScopedSession = sqlalchemy.orm.scoped_session
before
from elixir import *