-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
26 lines (22 loc) · 857 Bytes
/
test.py
File metadata and controls
26 lines (22 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from urllib import response
import requests
import os
if not os.path.exists("northwind.sql"):
test = "https://raw.githubusercontent.com/jpwhite3/northwind-SQLite3/master/src/create.sql"
response = requests.get(test)
with open("northwind.sql", "w") as f:
f.write(response.text)
sql = []
with open("northwind.sql", "r") as f:
for line in f.readlines():
if line.startswith("--"):
if len(sql) != 0:
sql = ['PRAGMA foreign_keys=off;', 'BEGIN TRANSACTION;'] + sql + ['COMMIT;']
response = requests.post("http://localhost:8787/query", data="\n".join(sql))
print(response.text)
if response.status_code != 200:
break
sql = []
else:
sql.append(line.strip())
requests.get("http://localhost:8787/gc")