summaryrefslogblamecommitdiffstats
path: root/dash/db.py
blob: 1f87a09210d6c5cc9191bd77eb322c7ade0d527d (plain) (tree)
1
2
3
4
5
6
7
8
9


                      



                               

                    
                                                                                                                                                                                                           









                        
#!/usr/bin/env python3

import pymysql
import configparser

c = configparser.ConfigParser()
c.read('config.ini')

def getConnection():
    db = pymysql.connect(host=c.get('db', 'host'), user=c.get('db', 'username'), password=c.get('db', 'password'), database=c.get('db', 'name'), charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor)
    return db

def closeConnection(db):
    db.commit()
    db.close()