-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.py
More file actions
27 lines (19 loc) · 697 Bytes
/
util.py
File metadata and controls
27 lines (19 loc) · 697 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
27
import pymysql.cursors
class DBConnectionManager(object):
def __init__(self, app):
self.app = app
self._generate_db()
@property
def db(self):
if not self._db.open:
self._generate_db()
return self._db
def _generate_db(self):
self.app.logger.info("Generating DB Connection")
self._db = pymysql.connect(host="localhost",
db="wsi_sample_project",
user="root",
cursorclass=pymysql.cursors.DictCursor)
def coerce_products(*products):
for product in products:
product["price"] = float(product["price"])