I'm trying to use SQLAlchemy to extract certain data. In this case, its for obtaining the age from a list of peopls stored in the "Profiles" class. However, when doing so, I get an error stating that: 'map' object has no attribute 'query'. I've tried doing this various other ways but it still results with an attribute error of sorts which makes me believe I'm not properly connecting or setting it up right?
profile_db = map(
lambda uri: sessionmaker(bind=create_engine(uri), autoflush=True)(),
[PROFILE_URI]
)
class pull_age(object):
def on_get(self, req, res):
person_age = profile_db.query(Profile).filter(Profile.id == req).first
res.json = {'age of person': person_age}
mapreturns back a map object not a list. You'd need to wrap your map call withlistto covert back to a list. Though now, you'd be calling thequerymethod on a list?AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'list(map(lambda ... )). I'm not so familiar with sqlalchemy, but my suspicion is that you want to call the query method on each element of theprofile_dblist and not the list itself.