summaryrefslogblamecommitdiffstats
path: root/db.py
blob: b417cfda91a3979e07e8f3f6ad89e685f1eb65cc (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(c.get('db', 'host'), c.get('db', 'username'), c.get('db', 'password'), c.get('db', 'name'), cursorclass=pymysql.cursors.DictCursor)
    return db

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