From c718c7abfedb89690aa5978981bf031321a7a42e Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sun, 20 Dec 2020 16:29:01 +0100 Subject: [PATCH] Remove generated column from db --- projects/project-3/backend/db_init.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/project-3/backend/db_init.py b/projects/project-3/backend/db_init.py index 14d44bc..d1d82f7 100644 --- a/projects/project-3/backend/db_init.py +++ b/projects/project-3/backend/db_init.py @@ -77,7 +77,7 @@ def init_database(): common_name TEXT, lat REAL, lon REAL, - id_num INTEGER AS (CAST(SUBSTR(id, 12) as INTEGER)) STORED + id_num INTEGER )""") conn.execute("""CREATE TABLE IF NOT EXISTS accidents( id INTEGER PRIMARY KEY, @@ -118,10 +118,10 @@ def import_bikepoints(): LOG.info("Importing bikepoints") conn = sqlite3.connect(DB_NAME, timeout=300) points = json.loads(requests.get("https://api.tfl.gov.uk/BikePoint").text) - points = list(map(lambda p: (p['id'], p['commonName'], p['lat'], p['lon']), points)) + points = list(map(lambda p: (p['id'], p['commonName'], p['lat'], p['lon'], int(p['id'][11:])), points)) LOG.info(f"Writing {len(points)} bikepoints to DB") - conn.executemany("INSERT OR IGNORE INTO bike_points VALUES (?, ?, ?, ?)", points) + conn.executemany("INSERT OR IGNORE INTO bike_points VALUES (?, ?, ?, ?, ?)", points) conn.commit() conn.close() LOG.info("Bikepoints imported")