-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.py
32 lines (29 loc) · 914 Bytes
/
database.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
"Database Operations"
import psycopg2
def getStationData(db_cursor, stationId):
"Returns Alexa Skill Data For Specific Station Id"
query = 'select gas_alexa_skill_station(%s)'
db_cursor.execute(query, [stationId])
data = db_cursor.fetchone()
if data:
return data[0]
else:
return []
def getGeoLocationData(db_cursor, latitude, longitude):
"Returns Alexa Skill Data for Geo Search of Stations"
query = 'select gas_alexa_skill_geolocation(%s, %s)'
db_cursor.execute(query, [latitude, longitude])
data = db_cursor.fetchone()
if data:
return data[0]
else:
return []
def getPostalCodeData(db_cursor, postal_code):
"Returns Alexa Skill Data for Postal Code search"
query = 'select gas_alexa_skill(%s)'
db_cursor.execute(query, [postal_code])
data = db_cursor.fetchone()
if data:
return data[0]
else:
return []