diff --git a/projects/project-3/backend/db_init.py b/projects/project-3/backend/db_init.py index 9ad85d0..14d44bc 100644 --- a/projects/project-3/backend/db_init.py +++ b/projects/project-3/backend/db_init.py @@ -95,9 +95,21 @@ def init_database(): def create_indexes(): LOG.info("Try to create indexes") conn = sqlite3.connect(DB_NAME, timeout=300) + LOG.info("Starting to build index: idx_date_of_start_date") conn.execute("""CREATE INDEX IF NOT EXISTS idx_date_of_start_date ON usage_stats (date(start_date, "unixepoch"))""") conn.commit() + LOG.info("Created index: idx_date_of_start_date") + LOG.info("Starting to build index: idx_end_station_id_date_of_start_date") + conn.execute("""CREATE INDEX IF NOT EXISTS "idx_end_station_id_date_of_start_date" + ON "usage_stats" ("end_station_id" ASC, date(start_date, "unixepoch"))""") + conn.commit() + LOG.info("Created index: idx_end_station_id_date_of_start_date") + LOG.info("Starting to build index: idx_start_station_id_date_of_start_date") + conn.execute("""CREATE INDEX IF NOT EXISTS "idx_start_station_id_date_of_start_date" + ON "usage_stats" ("start_station_id" ASC, date("start_date", "unixepoch"))""") + conn.commit() + LOG.info("Created index: idx_start_station_id_date_of_start_date") conn.close() LOG.info("Indexes created")