from peewee import * from datetime import datetime from playhouse.sqlite_ext import * import json # Initialize database db = SqliteExtDatabase('estate.db') db_description = """Table "project" - list of real estate projects (novostavby) in Czech Republic url: url of the project. title: title of the project deposit: percentage of payment before completion min_price: lowest available apartment price in CZK with VAT status: status of the project (preparation, selling, sold out) city: city of the project lat: GPS latitude coordinates lng: GPS longitude coordinates start_year: year of construction start end_year: estimated year of construction end developer: name of the construction company ignore: if True, the project does not have any apartments for sale Apartment prices are stored in separate columns for each type: price_1kk, price_2kk, price_3kk, etc. """ class Project(Model): # Basic information url = CharField(unique=True) title = CharField(null=True) # Financial information deposit = IntegerField(null=True) # percentage min_price = IntegerField(null=True) # CZK with VAT # Apartment prices by type price_1kk = IntegerField(null=True) price_2kk = IntegerField(null=True) price_3kk = IntegerField(null=True) price_4kk = IntegerField(null=True) price_5kk = IntegerField(null=True) price_6kk = IntegerField(null=True) price_7kk = IntegerField(null=True) price_8kk = IntegerField(null=True) price_9kk = IntegerField(null=True) price_10kk = IntegerField(null=True) price_1_1 = IntegerField(null=True) price_2_1 = IntegerField(null=True) price_3_1 = IntegerField(null=True) price_4_1 = IntegerField(null=True) price_5_1 = IntegerField(null=True) price_6_1 = IntegerField(null=True) price_7_1 = IntegerField(null=True) price_8_1 = IntegerField(null=True) price_9_1 = IntegerField(null=True) price_10_1 = IntegerField(null=True) # Project information status = CharField(null=True) city = CharField(null=True) lat = FloatField(null=True) lng = FloatField(null=True) start_year = IntegerField(null=True) end_year = IntegerField(null=True) developer = CharField(null=True) # Additional data ignore = BooleanField(null=True) content = TextField(null=True) # Keep raw content for reference structure = JSONField(null=True) # Keep JSON for backward compatibility created_at = DateTimeField(default=datetime.now) class Meta: database = db def init_database(): """Initialize the database and create tables""" print("Initializing database...") db.connect() db.drop_tables([Project]) db.create_tables([Project]) print("Created tables successfully!") db.close() if __name__ == "__main__": init_database()