-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitDB.py
More file actions
33 lines (25 loc) · 773 Bytes
/
initDB.py
File metadata and controls
33 lines (25 loc) · 773 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
27
28
29
30
31
32
33
import sqlite3
import csv
conn = sqlite3.connect("accounts.db")
def init_db():
conn.execute("DROP TABLE ACCOUNT")
conn.commit()
conn.execute("""
CREATE TABLE IF NOT EXISTS ACCOUNT(
ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
ACCOUNT TEXT NOT NULL,
PASSWORD TEXT NOT NULL
)
""")
conn.commit()
file = open("names.csv")
name_reader = csv.reader(file)
next(name_reader)
for i in name_reader:
conn.execute(f"INSERT INTO ACCOUNT(ACCOUNT,PASSWORD) VALUES('{i[0]}','{i[0]}')")
conn.commit()
flag = open("flag.txt","r").readline()
conn.execute(f"INSERT INTO ACCOUNT(ACCOUNT, PASSWORD) VALUES('admin', '{flag}')")
conn.commit()
if __name__ == "__main__":
init_db()