I am trying a pyramid creating a new project. I choose PostgreSQL and sqlalchemy. So far I have a manually created photo table and a model for it:
class Photo(Base): """ The SQLAlchemy declarative model class for a Photo object. """ __tablename__ = 'photo' id = Column(Integer, primary_key=True) name = Column(Text) filename = Column(Text) cat_id = Column(Integer) viewed = Column(Integer) created = Column(DateTime) def __init__(self, name): self.name = name
Then in the view, I try to filter out some entries:
walls = DBSession.query(Photo).filter(Photo.cat_id == 20).limit(10)
But this small group of code does not work, I had an error:
[sqlalchemy.engine.base.Engine][Dummy-2] {'param_1': 1, 'cat_id_1': 20} *** sqlalchemy.exc.ProgrammingError: (ProgrammingError) relation "photo" does not exist LINE 2: FROM photo ^ 'SELECT photo.id AS photo_id, photo.name AS photo_name, photo.filename AS photo_filename, photo.cat_id AS photo_cat_id, photo.viewed AS photo_viewed, photo.created AS photo_created, photo.amazon_folder AS photo_amazon_folder \nFROM photo \nWHERE photo.cat_id = %(cat_id_1)s \n LIMIT %(param_1)s' {'param_1': 1, 'cat_id_1': 20}
The rule for connecting to DB is true:
sqlalchemy.url = postgres://me: pwd@localhost :5432/walls
Any suggestions?
source share