-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhashdatabase.py
More file actions
60 lines (46 loc) · 1.73 KB
/
hashdatabase.py
File metadata and controls
60 lines (46 loc) · 1.73 KB
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
import __main__
import mysql.connector
def find_hash(hash):
print('starting hash search')
db = mysql.connector.connect(user='{}'.format(__main__._sql_user),
password='{}'.format(__main__._sql_pass),
host='{}'.format(__main__._sql_server),
database='{}'.format(__main__._sql_hashdb))
c = db.cursor()
c.execute('''
SELECT hash FROM sig WHERE hash='%s'
'''%(hash))
try:
print(__main__._sql_server)
__main__.q.put(c.fetchone()[0])
print('done')
except:
__main__.q.put('None')
def insert_new_hash(hash):
if find_hash(hash) == hash:
print('hash already in db.')
else:
print('this hash is new, adding now')
def get_count_hash():
db = mysql.connector.connect(user='{}'.format(__main__._sql_user),
password='{}'.format(__main__._sql_hashdb),
host='{}'.format(__main__._sql_server),
database='{}'.format(__main__._sql_hashdb))
c = db.cursor()
c.execute('''
SELECT COUNT(*) FROM sig
''')
print('ended')
return c.fetchone()[0]
def remove_hash(hash):
db = mysql.connector.connect(user='{}'.format(__main__._sql_hashdb),
password='{}'.format(__main__._sql_hashdb),
host='{}'.format(__main__._sql_server),
database='{}'.format(__main__._sql_hashdb))
c = db.cursor()
c.execute('''
DELETE FROM sig WHERE hash="{}"
'''.format(hash))
db.commit()
def update():
print('asdf')