I'm quite green with sqlalchemy so please excuse me if this question is very basic. I'm having a problem reading property values of an object after a query. First let me describe the layout of my application. I have a User class which is mapped into a database. The user class is defined as such: class User(Base): __tablename__ = 'users'
id = Column(Integer, primary_key=True) name = Column(String(40)) hash = Column(String(40)) salt = Column(String(16)) I have a Database class which I use as a wrapper for querying/updating the database. Snippet: class Database: def __init__(self, file): self.engine = create_engine('sqlite:///' + file, echo=False) self.Session = sessionmaker(bind=self.engine) m = metadata() m.create_all(self.engine) def add_user(self,name,passphrase): #generate a salt for the passphrase and save the hash #... code excluded user = User(name,salt,pw_hash) session = self.Session() session.add(user) session.commit() I ran into a problem when querying the database: def get_user(self,uname): session = self.Session() q = session.query(User).filter_by(name=str(uname)).first() session.close() return q The resulting User object is basically useless as none of its properties can be accessed (I'm assuming this is because the session has been closed). Now leaving the session open is not an option as I may need to delete the User from another session later. I believe what I need is "eager loading" of all the User properties. How would I accomplish this? thanks, hticker --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---