import csv import io import urllib.request import urllib.parse import ssl def runsql(sql: str) -> csv.DictReader: ssl._create_default_https_context = ssl._create_unverified_context sql_escaped = urllib.parse.urlencode({'sql': sql}) URL = 'https://driver-observer.thi.de/retrieve_arbitrary_sql.php' req = urllib.request.Request('{}?{}'.format(URL, sql_escaped)) req.add_header('Auth', 'Qnb7jfeGZM') with urllib.request.urlopen(req) as res: return csv.DictReader(io.StringIO(res.read().decode('utf-8'), newline=''))