#! /usr/bin/env python
# -*- coding: utf-8 -*-
import mysql.connector
class QyDb:
sql = []
conn = None
db = None
def __init__(self, host, username, password, database, port=3306, charset='utf8', tablePrefix=''):
self.host = host
self.username = username
self.password = password
self.database = database
self.port = int(port)
self.charset = charset
self.tablePrefix = tablePrefix
def connect(self):
if self.conn is None:
try:
self.conn = mysql.connector.connect(host=self.host, user=self.username, password=self.password,
database=self.database)
self.db = self.conn.cursor(dictionary=True)
if self.charset is not None:
self.query(
"SET character_set_connecti