Greetings, I'm using SQLAlchemy 0.6 with Python 2.6 medical-app/
facility/ recalls.py common/ __init__.py patient.py common.py settings.py So the application I'm working on has directory structure as above. Program starts when I run recalls.py (which is under /medical-app/facility). Also, recalls.py imports common.py (which is under medical-app/common/common.py). Common.py further imports settings.py which has code like following USERNAME = 'root' PASSWORD = '' SERVER = 'localhost' DB_NAME = localdb' DB = create_engine('mysql://'+USERNAME+':'+PASSWORD+'@'+SERVER +'/'+DB_NAME, pool_size = 20, pool_recycle=100) db_session = session.sessionmaker(bind=DB, expire_on_commit=False) alchemy_session = db_session() META = MetaData(DB) In patient.py, I've declarative style classes as below from common.settings import alchemy_session, DB, META from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Table Base = declarative_base() class Patient(Base): __table__ = Table('Patient', Base.metadata, autoload=True, autoload_with=DB) Then finally in recalls I do the following from common import alchemy_session from common.patient import Patient patient = alchemy_session.query(Patient).filter(Patient.patientId == 1).first()#this works patient = alchemy_session.query(Patient).filter(Patient.patientId == 2).first()#this fails #with following error ------------------------------------------------------------ patient = alchemy_session.query(Patient).filter( File "c:\python26\lib\site-packages\sqlalchemy-0.7.1-py2.6.egg \sqlalchemy\orm\ session.py", line 897, in query return self._query_cls(entities, self, **kwargs) File "c:\python26\lib\site-packages\sqlalchemy-0.7.1-py2.6.egg \sqlalchemy\orm\ query.py", line 105, in __init__ self._set_entities(entities) File "c:\python26\lib\site-packages\sqlalchemy-0.7.1-py2.6.egg \sqlalchemy\orm\ query.py", line 112, in _set_entities entity_wrapper(self, ent) File "c:\python26\lib\site-packages\sqlalchemy-0.7.1-py2.6.egg \sqlalchemy\orm\ query.py", line 2800, in __init__ "expected - got '%r'" % column sqlalchemy.exc.InvalidRequestError: SQL expression, column, or mapped entity exp ected - got '<class 'vi_pycommon.patient.Patient'>' D:\integration-scripts \allendale_bone_joint>alchemy_session.query(Patient).filte r(Patient.patientId == 2).first() ----------------------- so if you notice this line didn't fail patient = alchemy_session.query(Patient).filter(Patient.patientId == 1).first() but next line did, which was patient = alchemy_session.query(Patient).filter(Patient.patientId == 2).first()#this fails So I'm actually really stumped as to why this second call is failing with that error. I am absolutely sure I'm doing something wrong here, so kindly let me know how can I fix this one. Thanks in advance for all help. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.