-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
26 lines (18 loc) · 690 Bytes
/
main.py
File metadata and controls
26 lines (18 loc) · 690 Bytes
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
from foodsearch import *
from databasedriver import DatabaseDriver
from foodsearch import FoodSearch
from queries import insert_business_table, create_business_table, create_business_schema
def to_string(data):
return [str(value) for value in data.values()]
if __name__ == '__main__':
paramester = {
'term': 'food',
'location': 'United States',
'price': 2
}
search = FoodSearch(**paramester)
db = DatabaseDriver()
db.setup()
queries = [insert_business_table.format(*to_string(result)) for result in search.get_results()]
query_to_execute = "BEGIN; \n" + '\n'.join(queries) + "\nCOMMIT;"
db.execute_query(query_to_execute)