forked from alexandrust88/vulpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_init.py
executable file
·50 lines (33 loc) · 1.01 KB
/
db_init.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
import os
import sqlite3
def db_init_users():
users = [
('admin', 'SuperSecret'),
('elliot', '123123123'),
('tim', '12345678')
]
conn = sqlite3.connect('db_users.sqlite')
c = conn.cursor()
c.execute("CREATE TABLE users (username text, password text, failures int, mfa_enabled int, mfa_secret text)")
for u,p in users:
c.execute("INSERT INTO users (username, password, failures, mfa_enabled, mfa_secret) VALUES ('%s', '%s', '%d', '%d', '%s')" %(u, p, 0, 0, ''))
conn.commit()
conn.close()
def db_init_posts():
conn = sqlite3.connect('db_posts.sqlite')
c = conn.cursor()
c.execute("CREATE TABLE posts (date date, username text, text text)")
conn.commit()
conn.close()
if __name__ == '__main__':
try:
os.remove('db_users.sqlite')
except FileNotFoundError:
pass
try:
os.remove('db_posts.sqlite')
except FileNotFoundError:
pass
db_init_users()
db_init_posts()