blob: 8457dd49f72fafeeb414343a3a958ba9fea1e471 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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 get_cursor(self):
return self.db_cursor
def fetch(self, db_name, sql, params):
self.db_cursor.execute(sql.replace('#db#', db_name), params)
row = self.db_cursor.fetchone()
return row
|