-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_authenticator_db.py
executable file
·43 lines (36 loc) · 1.08 KB
/
create_authenticator_db.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
#!/usr/bin/env python
"""
Creates and empty sqlite database file for brmdoor_authenticator.UidAuthenticator.
Give filename as first argument.
"""
import sys
import sqlite3
def createTables(cursor):
"""Create DB tables in an empty database
@:param cursor cursor to sqlite DB
"""
cursor.execute("""CREATE TABLE authorized_uids(
id INTEGER PRIMARY KEY AUTOINCREMENT,
uid_hex TEXT,
nick TEXT)
""")
cursor.execute("""CREATE TABLE authorized_hmac_keys(
id INTEGER PRIMARY KEY AUTOINCREMENT,
uid_hex TEXT,
key_hex TEXT,
nick TEXT)
""")
cursor.execute("""CREATE TABLE authorized_desfires(
id INTEGER PRIMARY KEY AUTOINCREMENT,
uid_hex TEXT,
nick TEXT)
""")
if __name__ == "__main__":
if len(sys.argv) < 2:
print >> sys.stderr, "You must specify filename as arg1 where the DB is to be created"
filename = sys.argv[1]
conn = sqlite3.connect(filename)
cursor = conn.cursor()
createTables(cursor)
conn.commit()
conn.close()