import csv import io import urllib.request import urllib.parse def runsql(sql: str) -> csv.DictReader: 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=''))