]> git.mxchange.org Git - fba.git/blob - preload_db.py
added other instances to preload
[fba.git] / preload_db.py
1 import sqlite3
2 from hashlib import sha256
3
4 conn = sqlite3.connect("blocks_preloaded.db")
5 c = conn.cursor()
6
7 with open("pleroma_instances.txt", "r") as f:
8     while line := f.readline():
9         print(line.rstrip(), sha256(bytes(line.rstrip(), "utf-8")).hexdigest())
10         c.execute(f"insert into instances select \"{line.rstrip()}\", \"{sha256(bytes(line.rstrip(), 'utf-8')).hexdigest()}\"")
11         conn.commit()
12
13 with open("mastodon_instances.txt", "r") as f:
14     while line := f.readline():
15         print(line.rstrip(), sha256(bytes(line.rstrip(), "utf-8")).hexdigest())
16         c.execute(f"insert into instances select \"{line.rstrip()}\", \"{sha256(bytes(line.rstrip(), 'utf-8')).hexdigest()}\"")
17         conn.commit()
18
19 with open("other_instances.txt", "r") as f:
20     while line := f.readline():
21         print(line.rstrip(), sha256(bytes(line.rstrip(), "utf-8")).hexdigest())
22         c.execute(f"insert into instances select \"{line.rstrip()}\", \"{sha256(bytes(line.rstrip(), 'utf-8')).hexdigest()}\"")
23         conn.commit()
24
25 conn.close()