Open mkeneqa opened 3 years ago
def Connect(self, use_cursor_dict=False):
if use_cursor_dict:
self.USE_CRSR_DICT = True
return pymysql.connect(
host=self.HOST,
user=self.DBUSR,
password=self.DBPSWD,
db=self.DBNAME,
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor
)
else:
self.USE_CRSR_DICT = False
return pymysql.connect(
host=self.HOST,
user=self.DBUSR,
password=self.DBPSWD,
db=self.DBNAME,
charset='utf8mb4'
)
Have returned rows be in dictionary form.
http://zetcode.com/python/pymysql/
eg: