I'm attempting to get Elixir (trunk) with SQLAlchemy 0.4 running
inside a multi-threaded environment (CherryPy) without much luck. I
read the previous list postings I could find but none of the solutions
offered seem to help (or I am misunderstanding the advice). I've
create a small test script which highlights the problem I'm
experiencing:
"""START OF ThreadTest.py"""
from elixir import *
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.sessioncontext import SessionContext
import sqlalchemy
__metadata__ = sqlalchemy.MetaData()
__session__ = scoped_session(sessionmaker(autoflush=True))
class Pet(Entity):
has_field('name', Unicode(30))
using_options(tablename='pet')
def bind(engine):
global __metadata__, __session__
__metadata__.bind = engine
__session__.configure(bind=engine)
def init():
create_all()
felix = Pet(name='Felix')
__session__.flush()
if __name__ == "__main__":
import threading
import time
engine = sqlalchemy.create_engine("sqlite:///:memory:")
bind(engine)
t = threading.Thread(target=init)
t.start()
t.join()
Pet.query().all()
"""END OF ThreadTest.py"""
Running "python ThreadTest.py" throws:
sqlalchemy.exceptions.OperationalError: (OperationalError) no such
table: pet u'SELECT pet.id AS pet_id, pet.name AS pet_name \nFROM pet
ORDER BY pet.oid' []
Any pointers on what I'm doing wrong would be appreciated.
Schiavo
Simon
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---