summaryrefslogtreecommitdiff
path: root/playoff/db.py
blob: aa0c2e2618576986f730224dfddbb37462e1a04c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import mysql.connector

class PlayoffDB(object):

    db_cursor = None

    def __init__(self, settings):
        self.database = mysql.connector.connect(
            user=settings['user'],
            password=settings['pass'],
            host=settings['host'],
            port=settings['port']
        )
        self.db_cursor = self.database.cursor(buffered=True)

    def fetch(self, db, sql, params):
        self.db_cursor.execute(sql.replace('#db#', db), params)
        row = self.db_cursor.fetchone()
        return row