Fixing __repr__ for RightmoveListing and adding a small testing script
This commit is contained in:
parent
8698b41e0e
commit
f30115eecd
2 changed files with 16 additions and 5 deletions
11
rec/db.py
11
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 "<User(name='%s', fullname='%s', nickname='%s')>" % (
|
||||
self.name,
|
||||
self.fullname,
|
||||
self.nickname,
|
||||
return "<RightMoveListing(id='{}', price='{}', lat={}, lon={}')>".format(
|
||||
self.id,
|
||||
self.price,
|
||||
self.lat,
|
||||
self.lon,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
10
testing.py
Normal file
10
testing.py
Normal file
|
|
@ -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)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue