Initial commit: Rightmove fetch, database, caching, poetry etc.
- Fetching rightmove listing api - Memoizing query - Writing to sqlite database with sqlalchemy - Poetry dependencies
This commit is contained in:
commit
4ee7ae16c4
12 changed files with 3236 additions and 0 deletions
34
db.py
Normal file
34
db.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy import Column, Integer, String, JSON, FLOAT
|
||||
|
||||
engine = create_engine("sqlite:///sqlite.db", echo=True)
|
||||
session = Session(engine)
|
||||
|
||||
from sqlalchemy.orm import declarative_base
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
class RightmoveListing(Base):
|
||||
__tablename__ = "rightmove"
|
||||
id = Column(Integer, primary_key=True)
|
||||
price = Column(FLOAT)
|
||||
listing_json = Column(JSON, nullable=True)
|
||||
detail_json = Column(JSON, nullable=True)
|
||||
updated_timestamp = Column(Integer, nullable=True)
|
||||
distance_to_office_minutes = Column(FLOAT, nullable=True)
|
||||
|
||||
def save(self):
|
||||
session.add(self)
|
||||
session.commit()
|
||||
|
||||
def __repr__(self):
|
||||
return "<User(name='%s', fullname='%s', nickname='%s')>" % (
|
||||
self.name,
|
||||
self.fullname,
|
||||
self.nickname,
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
Base.metadata.create_all(engine)
|
||||
Loading…
Add table
Add a link
Reference in a new issue