-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpgfunc.py
executable file
·69 lines (51 loc) · 1.24 KB
/
gpgfunc.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
import sqlite3 as db
from datetime import datetime
DATE = str(datetime.now())
# Initializes the data base
def init():
conn = db.connect("gpgkeys.db")
cur = conn.cursor()
sql = '''
CREATE TABLE IF NOT EXISTS gpgkeys (
gpg_key string,
repo string,
time string
)
'''
cur.execute(sql)
conn.commit()
# Logs the user input
def log(gpg_key, repo_name):
conn = db.connect("gpgkeys.db")
cur = conn.cursor()
# data = (gpg_key, repo, DATE)
sql = '''insert into gpgkeys values (
'{}', '{}', '{}'
)
'''.format(gpg_key, repo_name, DATE)
cur.execute(sql)
conn.commit()
# Prints the database
def view(repo_name=None):
conn = db.connect("gpgkeys.db")
cur = conn.cursor()
if repo_name:
sql = '''
select * from gpgkeys where repo = '{}'
'''.format(repo_name)
else:
sql = '''
select * from gpgkeys
'''
cur.execute(sql)
results = cur.fetchall()
return results
def delete(repo_name):
conn = db.connect("gpgkeys.db")
cur = conn.cursor()
sql = '''
delete from gpgkeys where repo = '{}'
'''.format(repo_name)
cur.execute(sql)
conn.commit()