forked from henami2207/demo
-
Notifications
You must be signed in to change notification settings - Fork 7
/
security.py
36 lines (28 loc) · 1.05 KB
/
security.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
import sqlite3
import requests
class ResidentsDb:
def __init__(self, table_name, mapping_function, duration):
"""Set location on disk data cache will reside.
Also sets the table name and refresh duration
"""
self.table_name = table_name
self.mapping_function = mapping_function
self.disk_location = DISK_LOCATION_DEFAULT
self.duration = duration
self.conn = None
self.cursor = None
def open(self):
"""Opens connection to sqlite database."""
self.conn = sqlite3.connect(self.dbname)
self.cursor = self.conn.cursor()
def get_id_from_name(self, name):
"""Get id of resident from name."""
data = self.cursor.execute(
"SELECT id FROM userdata WHERE Name ={};".format(name))
self.conn.commit()
return data
def fetch_version(request):
"""Fetch verison of bgmi."""
version = requests.get("https://pypi.python.org/pypi/bgmi/json",
verify=False).json()["info"]["version"]
return version