Download all ship ids and names from ESI and save in OPTIONS_OBJECT.
(conn, cur)
| 82 | |
| 83 | |
| 84 | def prepare_ship_data(conn, cur): |
| 85 | ''' |
| 86 | Download all ship ids and names from ESI and save in OPTIONS_OBJECT. |
| 87 | ''' |
| 88 | ship_data_date = config.OPTIONS_OBJECT.Get("ship_data_date", 0) |
| 89 | max_age = config.MAX_SHIP_DATA_AGE |
| 90 | max_date = datetime.date.today() - datetime.timedelta(days=max_age) |
| 91 | if ship_data_date == 0 or ship_data_date < max_date: |
| 92 | config.OPTIONS_OBJECT.Set("ship_data", apis.get_ship_data()) |
| 93 | config.OPTIONS_OBJECT.Set("ship_data_date", datetime.date.today()) |
| 94 | # Populate ships table with ids and names for all ships in game |
| 95 | cur.executemany( |
| 96 | '''INSERT OR REPLACE INTO ships (id, name) VALUES (?, ?)''', |
| 97 | config.OPTIONS_OBJECT.Get("ship_data", 0) |
| 98 | ) |
| 99 | conn.commit() |
| 100 | |
| 101 | |
| 102 | def write_many_to_db(conn, cur, query_string, records, keepalive=True): |
no test coverage detected