Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Impossible to initialize Elixir

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.

like image 277
Pedro Piñera Buendia Avatar asked Jan 07 '13 17:01

Pedro Piñera Buendia


3 Answers

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
like image 50
Luca Invernizzi Avatar answered Nov 12 '22 13:11

Luca Invernizzi


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, \
like image 38
Jaimy Azle Avatar answered Nov 12 '22 12:11

Jaimy Azle


seems like sqlalchemy 0.8 changed the location of ScopedSession

http://elixir.ematia.de/trac/ticket/121

like image 2
Mark Avatar answered Nov 12 '22 12:11

Mark