|
|
|
@ -25,7 +25,7 @@ def get_connection() -> sqlite3.Connection:
|
|
|
|
d[col[0]] = row[idx]
|
|
|
|
d[col[0]] = row[idx]
|
|
|
|
return d
|
|
|
|
return d
|
|
|
|
|
|
|
|
|
|
|
|
conn = sqlite3.connect(config.DB_PATH)
|
|
|
|
conn = sqlite3.connect(config.DB_PATH, check_same_thread=False)
|
|
|
|
conn.row_factory = dict_factory
|
|
|
|
conn.row_factory = dict_factory
|
|
|
|
yield conn
|
|
|
|
yield conn
|
|
|
|
conn.close()
|
|
|
|
conn.close()
|
|
|
|
@ -58,7 +58,7 @@ def save_locations(conn: sqlite3.Connection, locations: List[dict]):
|
|
|
|
def find_locations(conn: sqlite3.Connection,
|
|
|
|
def find_locations(conn: sqlite3.Connection,
|
|
|
|
*,
|
|
|
|
*,
|
|
|
|
country: str,
|
|
|
|
country: str,
|
|
|
|
city: str = '') -> List[Location]:
|
|
|
|
city: str = None) -> List[Location]:
|
|
|
|
sql = '''
|
|
|
|
sql = '''
|
|
|
|
SELECT DISTINCT id, country, city, region
|
|
|
|
SELECT DISTINCT id, country, city, region
|
|
|
|
FROM locations
|
|
|
|
FROM locations
|
|
|
|
|