Export database
Signed-off-by: András Schmelczer <andras@schmelczer.dev>
This commit is contained in:
parent
365a8f3914
commit
1279724ee3
2 changed files with 6872 additions and 0 deletions
6842
fizika.json
Normal file
6842
fizika.json
Normal file
File diff suppressed because it is too large
Load diff
30
sql2json.py
Normal file
30
sql2json.py
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
import re
|
||||||
|
import json
|
||||||
|
|
||||||
|
regex = r"\((\d+), '(.*?)', '(.*?)', '(.*?)', '(.*?)', '(.*?)', '(.*?)', (\d), '(.+?)', '(.*?)'\)"
|
||||||
|
|
||||||
|
sql = open('db/fizika.sql')
|
||||||
|
lines = sql.readlines()
|
||||||
|
|
||||||
|
result = []
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
match = re.match(regex, line)
|
||||||
|
if match:
|
||||||
|
id, source, description, a, b, c, d, correct, type, image = match.groups()
|
||||||
|
image = f'{image}.{"png" if int(id) > 435 else "JPG"}' if image != '' else None
|
||||||
|
|
||||||
|
result.append({
|
||||||
|
"id": int(id),
|
||||||
|
"source": source,
|
||||||
|
"description": description,
|
||||||
|
"a": a,
|
||||||
|
"b": b,
|
||||||
|
"c": c,
|
||||||
|
"d": d,
|
||||||
|
"correct": int(correct),
|
||||||
|
"type": type,
|
||||||
|
"image": image,
|
||||||
|
})
|
||||||
|
|
||||||
|
json.dump(result, open('fizika.json', 'w+'), indent=2)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue