class mssql(object):

    def __init__(self, host, user, passwd, db):
        import pymssql
        self.con = pymssql.connect(host=host,user=user,password=passwd,database=db)
        self.x = self.con.cursor(as_dict=True)

    def query(self, query, commit, *args):
        self.x.execute(query, (args))
        if commit == 1:
            self.commit()
        return self.x.fetchall()
    
    def commit(self):
        self.con.commit()

    def close(self):
        self.x.close()
        self.con.close()
                

class mysql(object):

    def __init__(self, host, user, passwd, db):
        import pymysql
        self.con = MySQLdb.connect(host=host,user=user,passwd=passwd,db=db)
        self.x = self.con.cursor(pymysql.cursors.DictCursor)

    def query(self, query, commit, *args):
        self.x.execute(query, (args))
        if commit == 1:
            self.commit()
        return self.x.fetchall()
    
    def commit(self):
        self.con.commit()

    def close(self):
        self.x.close()
        self.con.close()


class sqlite(object):

    def __init__(self,dbname):
        import sqlite3
        self.con = sqlite3.connect(dbname)
        self.x = self.con.cursor()

    def query(self, query, commit, *args):
        self.x.execute(query, (args))
        if commit == 1:
            self.commit()
        return self.x.fetchall()

    def commit(self):
        self.con.commit()
    
    def close(self):
        self.x.close()
        self.con.close()
