PHD Project - Driver energy prediction
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
567 B

2 years ago
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=''))