Si alguno ve alguna forma de mejorar la clase por favor aporte
Código:
Saludos import MySQLdb
class GestorBD(object):
instance=None
def __new__(cls, *args, **kargs):
if cls.instance is None:
cls.instance=object.__new__(cls, *args, **kargs)
return cls.instance
conn = ""
def Connect(self,server):
self.conf = {"host":server["host"],
"user":server["user"],
"passwd":server["passwd"],
"db":server["db"]}
try:
self.conn = MySQLdb.connect(**self.conf)
except:
return False
def Disconnect(self):
self.conn.close()
def execute(self, consulta):
self.cursor=self.conn.cursor()
try:
self.cursor.execute(consulta)
registros=self.cursor.fetchall()
return registros
except MySQLdb.Error, e:
return False
self.conn.commit()
self.cursor.close
def executeone(self, consulta):
self.cursor=self.conn.cursor()
try:
self.cursor.execute(consulta)
registro=self.cursor.fetchone ()
return registro
except MySQLdb.Error, e:
return False
self.conn.commit()
self.cursor.close


