blob: 7b4f5b5c6e6432b68f1ee6d309bfab3632bfaaf7 (
plain)
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
27
|
#!/usr/bin/env nix-shell
#! nix-shell -p python310 -i python
import json
import sqlite3
con = sqlite3.connect("pokemans.db")
cur = con.cursor()
cur.execute("""
CREATE TABLE pokemon
( dex_id TEXT PRIMARY KEY
, name TEXT UNIQUE
, seen BOOLEAN NOT NULL DEFAULT FALSE
, caught BOOLEAN NOT NULL DEFAULT FALSE
, complete BOOLEAN NOT NULL DEFAULT FALSE
);""")
with open("./pokemans.json", "r") as fin:
data = fin.read().rstrip()
mans = json.loads(data)
for man in mans:
cur.execute("INSERT INTO pokemon(dex_id, name) VALUES (?1, ?2)", (man["id"], man["name"]))
con.commit()
con.close()
|