From f30115eecd28c00d33f651587173138d0705445f Mon Sep 17 00:00:00 2001 From: Kadir Tugan Date: Sat, 18 Nov 2023 13:25:00 +0200 Subject: [PATCH] Fixing __repr__ for RightmoveListing and adding a small testing script --- rec/db.py | 11 ++++++----- testing.py | 10 ++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 testing.py diff --git a/rec/db.py b/rec/db.py index 22058eb..66f7362 100644 --- a/rec/db.py +++ b/rec/db.py @@ -1,6 +1,6 @@ from sqlalchemy import create_engine from sqlalchemy.orm import Session -from sqlalchemy import Column, Integer, String, JSON, FLOAT +from sqlalchemy import Column, Integer, JSON, FLOAT from sqlalchemy.orm import declarative_base engine = create_engine("sqlite:///sqlite.db", echo=True) @@ -26,10 +26,11 @@ class RightmoveListing(Base): session.commit() def __repr__(self): - return "" % ( - self.name, - self.fullname, - self.nickname, + return "".format( + self.id, + self.price, + self.lat, + self.lon, ) diff --git a/testing.py b/testing.py new file mode 100644 index 0000000..4288538 --- /dev/null +++ b/testing.py @@ -0,0 +1,10 @@ +from rec.db import RightmoveListing, session +from sqlalchemy import select + +if __name__ == '__main__': + print("x") + x = select(RightmoveListing).where(RightmoveListing.price <600000) + print("y") + d = list(session.execute(x)) + print(d) +