Remove generated column from db
This commit is contained in:
parent
69b4d0eb33
commit
c718c7abfe
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user