-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_handler.py
38 lines (34 loc) · 933 Bytes
/
db_handler.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
from pydblite import Base
def get_cursor(db_name):
if db_name == 'weather_data':
db = Base('storage/weather_data.pdl')
if not db.exists():
db.create(
'low',
'tmw',
'high',
'temp',
'date',
'text',
'code',
'history',
'uniq_id',
'location',
'astronomy',
'atmosphere',
'country_name',
'created_date',
'location_name'
)
elif db_name == 'locations':
db = Base('storage/locations.pdl')
if not db.exists():
db.create(
'uniq_id',
'location',
'created_date'
)
else:
raise Exception('Please Enter Valid Name!')
cursor = db.open()
return cursor