d[col[0]] = row[idx] return d if hasattr('router_4', 'conn'): router_4.conn.close() print("connection closed") else: router_4.conn = sqlite3.connect('northwind.db', check_same_thread=False) router_4.conn.text_factory = lambda b: b.decode(errors="ignore").strip( ) router_4.conn.row_factory = dict_factory print("connection created") router_4.sql_dict = dict() #### def extract_end_point_from_request(request: Request): my_url = request.url.path[1::].lower() try: my_url = my_url[0:my_url.index("/"):] except ValueError: pass finally: return my_url def extract_sql_from_endpoint(end_point: str): sql = router_4.sql_dict[end_point]