本文整理汇总了Python中db_class.Connection.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.commit方法的具体用法?Python Connection.commit怎么用?Python Connection.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db_class.Connection
的用法示例。
在下文中一共展示了Connection.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_user
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def save_user(self,full_name = None, last_name = None, username = None, password = None,
email = None, state = None, phone = None, type_user = None,subsidiary = None,address=None,description=None):
"""Saves new user to database. returns None on
'user with that username already exists'
Parameters:
full_name: Name user
last_name: Last name user
username: username by ces
password: key user
email: email user
state: state of user - ENABLE - DISABLE
date_user: date of creation
phone: phone user
type_user: rol user - ADMIN - GUESS ---
Return:
True: wheather insert a new User is insert database
False: wheather no insert in database
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if self.get_by_username(username)[0]:
raise Exception("El nombre de usuario <b>"+username+"</b> ya existe")
self.response= _cnx.no_single_query("INSERT INTO usuarios (nombrecompletousuario,apellidosusuario,usuario,contraseniausuario,correousuario,estadousuario,telefonousuario,roldeusuario,codigosucursal,direccionusuario,descripcionusuario) "+
"VALUES ('"+full_name+"','"+last_name+"','"+username+"','"+password+"','"+email+"','"+state+"','"+phone+"',(select idrol from roles where roles.nombrerol='"+type_user+"' and codigosucursal= '"+subsidiary+"'),'"+subsidiary+"','"+address+"','"+description+"')")
_cnx.commit()
if self.debug: print "Insert (OK!)"
return True,"El usuario <b>"+full_name+"</b>, con nombre de usuario <b>"+username+"</b> ha sido creado"
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "NO Insert Error %s" % (exceptionValue)
return False, "%s" % (exceptionValue)
示例2: save_order
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def save_order(self,cedulacliente=None, responsable=None, estado=None, entrega=None, observaciones=None,
totalapagar=None, formadepago=None, recepcion=None, numeroorden=None, placa=None, numero_importacion=None,
marca=None, linea=None, modelo=None, clase_de_vehiculo=None, tipo_carroceria=None, combustible=None,
color=None, cilindraje=None, capacidad=None, sucursal=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if self.seek_NumOrder(numeroorden)[0]:
raise Exception("La Orden de Servicio "+numeroorden+"ya existe")
self.response= _cnx.no_single_query("INSERT INTO ordendetrabajo("+
"cedulacliente, responsable, estado, observaciones, "+
"totalapagar, formadepago, recepcion, numeroorden, placa, numero_importacion, "+
"marca, linea, modelo, clase_de_vehiculo, tipo_carroceria, combustible, "+
"color, cilindraje, capacidad,codigosucursal)"+
"VALUES ('"+cedulacliente+"', '"+responsable+"', '"+estado+"', '"+observaciones+"', "+
"'"+totalapagar+"', '"+formadepago+"', '"+recepcion+"', '"+numeroorden+"', '"+placa+"', '"+numero_importacion+"', "+
"'"+marca+"', '"+linea+"', '"+modelo+"', '"+clase_de_vehiculo+"', '"+tipo_carroceria+"', '"+combustible+"', "+
"'"+color+"', '"+cilindraje+"', '"+capacidad+"', '"+str(sucursal)+"');")
_cnx.commit()
if self.debug: print "Insert (OK!)"
return True, "La orden <b>'"+numeroorden+"'</b> ha sido <b>Guardada</b> con exito <br/> <b><a href='/setorderservice'>Ver lista</a></b> "
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "NO Insert Error %s" % (exceptionValue)
return False, "%s" % (exceptionValue)
示例3: update_user
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def update_user(self,identifier=None,full_name = None, last_name = None, username = None, password = None,
email = None, state = None, phone = None, type_user = None,address=None,description=None):
"""Saves new user to database. returns None on
'user with that username already exists'
Parameters:
full_name: Name user
last_name: Last name user
username: username by ces
password: key user
email: email user
state: state of user - ENABLE - DISABLE
date_user: date of creation
phone: phone user
type_user: rol user - ADMIN - GUESS ---
Return:
True: wheather insert a new User is insert database
False: wheather no insert in database
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if not self.get_by_identifier(identifier)[0]:
return False,"El nombre de usuario <b>"+username+"</b> no existe no se puede actualizar, comuniquese con el administrador"
if password:
self.response= _cnx.no_single_query("UPDATE usuarios SET nombrecompletousuario='"+full_name+"',apellidosusuario ='"+last_name+"',usuario='"+username+"',contraseniausuario='"+password+"',correousuario='"+email+"',estadousuario='"+state+"',telefonousuario='"+phone+"',roldeusuario='"+type_user+"',direccionusuario='"+address+"',descripcionusuario='"+description+"' where idusuario= '"+identifier+"' ")
else:
self.response= _cnx.no_single_query("UPDATE usuarios SET nombrecompletousuario='"+full_name+"',apellidosusuario ='"+last_name+"',usuario='"+username+"',correousuario='"+email+"',estadousuario='"+state+"',telefonousuario='"+phone+"',roldeusuario='"+type_user+"',direccionusuario='"+address+"',descripcionusuario='"+description+"' where idusuario= '"+identifier+"' ")
_cnx.commit()
if self.debug: print "Insert (OK!)"
return True,"El usuario <b>"+full_name+"</b>, con nombre de usuario <b>"+username+"</b> ha sido actualizado <br> <a href='/edituser'>Ver lista</a>"
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "NO Insert Error %s" % (exceptionValue)
return False, "%s" % (exceptionValue)
示例4: update_style
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def update_style(self,codigosucursal =None,theme= None, size = None, font=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
self.response= _cnx.no_single_query("UPDATE sucursal set configuracion = '{\"tema\":\""+theme+"\",\"tamanio\":\""+size+"\",\"fuente\":\""+font+"\"}' where codigosucursal = '"+str(codigosucursal)+"' ")
_cnx.commit()
if self.debug: print "Update (OK!)"
return True,"Todo a ido de maravilla, tu pagina se va actulizar para que veas los cambios."
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "No update %s" % (exceptionValue)
return False, " %s" % (exceptionValue)
示例5: delete_inventory
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def delete_inventory(self,codigo_inventario =None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if self.debug: print "try delete inventory "+str(codigo_inventario)+" "
self.response= _cnx.no_single_query("DELETE from inventario where codigo_inventario='"+str(codigo_inventario)+"'")
_cnx.commit()
if self.debug: print "DELETED (OK!)"
return True,"El inventario ha sido actualizado."
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "No update %s" % (exceptionValue)
示例6: update_quantity_inventory
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def update_quantity_inventory(self,codigo_inventario = None,cantidad= None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if self.debug: print "try update inventory "+codigo_inventario+""
print "UPDATE inventario set cantidad = '"+cantidad+"' where codigoinventario = '"+str(codigo_inventario)+"'"
self.response= _cnx.no_single_query("UPDATE inventario set cantidad = '"+cantidad+"' where codigoinventario = '"+str(codigo_inventario)+"'")
_cnx.commit()
if self.debug: print "Update (OK!)"
return True,"El inventario ha sido actualizado."
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "No update %s" % (exceptionValue)
示例7: delete_role
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def delete_role(self,idrol =None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if self.debug: print "try delete rol: "+str(idrol)+" "
self.response= _cnx.no_single_query("DELETE FROM ROLES WHERE idrol='"+str(idrol)+"'")
_cnx.commit()
if self.debug: print "DELETED (OK!)"
return True
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "No update %s" % (exceptionValue)
return False, "ERROR EN LA BASE DE DATOS %s" % (exceptionValue)
示例8: delete_vehicle
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def delete_vehicle(self,codigo_carro =None,):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if self.debug: print "try delete car "+str(codigo_carro)+" "
self.response= _cnx.no_single_query("DELETE from vehiculo where codigovehiculo='"+str(codigo_carro)+"'")
_cnx.commit()
if self.debug: print "DELETED (OK!)"
return True
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "No update %s" % (exceptionValue)
return False, "ERROR EN LA BASE DE DATOS %s" % (exceptionValue)
示例9: delete_subsidiary
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def delete_subsidiary(self,codigosucursal =None,):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if self.debug: print "try delete subsidiary "+str(codigosucursal)+" "
self.response= _cnx.no_single_query("DELETE from sucursal where codigosucursal='"+str(codigosucursal)+"'")
_cnx.commit()
if self.debug: print "DELETED (OK!)"
return True
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "No update %s" % (exceptionValue)
return False, "ERROR EN LA BASE DE DATOS %s" % (exceptionValue)
示例10: assign_order
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def assign_order(self,codigoorden=None,numeroorden=None,mecanico=None):
""" """
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if not self.seek_NumOrder(numeroorden)[0]:
raise Exception("La Orden de Servicio "+numeroorden+" NO existe")
self.response= _cnx.no_single_query("UPDATE ordendetrabajo SET responsable = '"+mecanico+"' WHERE codigoorden= '"+codigoorden+"' AND numeroorden = '"+numeroorden+"' ")
_cnx.commit()
if self.debug: print "Update (OK!)"
return True, "Orden Asignada Exitosamente"
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "NO Insert Error %s" % (exceptionValue)
return False, " %s" % (exceptionValue)
示例11: save_offer
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def save_offer(self,codigovehiculo=None, codigorepuesto=None, tipooferta=None, descripcionoferta=None, fechaoferta=None, valoroferta=None, fechainicio=None, fechafinal=None, uuid=None,estado=None,sucursal=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if self.exist_offer(codigovehiculo,codigorepuesto,tipooferta,valoroferta):
raise Exception("Esta oferta ya existe")
self.response= _cnx.no_single_query("INSERT INTO ofertas(codigovehiculo, codigorepuesto, tipooferta, descripcionoferta,fechaoferta, valoroferta, fechainicio, fechafinal,uuid,estado,codigosucursal) VALUES ('"+codigovehiculo+"','"+codigorepuesto+"','"+tipooferta+"','"+descripcionoferta+"','"+fechaoferta+"','"+valoroferta+"','"+fechainicio+"','"+fechafinal+"','"+uuid+"','"+estado+"','"+sucursal+"')")
_cnx.commit()
if self.debug: print "Insert (OK!)"
return True,"<center>La oferta <b>"+uuid+"</b> se ha creado con <b>éxito</b><br><a href='/listoffers'>Ver en la lista </a></center>"
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "NO Insert Error %s" % (exceptionValue)
return False, "%s" % (exceptionValue)
示例12: save_quotation
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def save_quotation(self,numerocotizacion=None,fecha=None,articulos=None,valorcotizacion=None,codigosucursal=None,codigocliente=None,imagenqr=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if self.seek_quotation(numerocotizacion)[0]:
raise Exception("This quotation= "+numerocotizacion+" is already")
self.response= _cnx.no_single_query("INSERT INTO cotizacion ( numerocotizacion, fecha, articulos,valorcotizacion, codigosucursal, codigocliente, imagenqr ) VALUES ( '"+numerocotizacion+"', '"+fecha+"', '"+articulos+"',"+valorcotizacion+", "+str(codigosucursal)+", "+codigocliente+", '"+imagenqr+"' )")
_cnx.commit()
if self.debug: print "Insert (OK!)"
return True, "Cotizacion <b>Guardada</b> <br/> <a href='/seequotations'>Ver lista</a>"
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "NO Insert Error %s" % (exceptionValue)
return False, "%s" % (exceptionValue)
示例13: update_offer
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def update_offer(self,codigooferta=None,codigovehiculo=None, codigorepuesto=None, tipooferta=None, descripcionoferta=None,valoroferta=None, fechainicio=None, fechafinal=None,estado=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if not self.exist_offerbyId(codigooferta):
raise Exception("Esta oferta no existe, no se puede actualizar")
self.response= _cnx.no_single_query("UPDATE ofertas set codigovehiculo='"+codigovehiculo+"',codigorepuesto='"+codigorepuesto+"',tipooferta='"+tipooferta+"',descripcionoferta='"+descripcionoferta+"',valoroferta='"+valoroferta+"',fechainicio='"+fechainicio+"',fechafinal='"+fechafinal+"',estado='"+estado+"' WHERE codigooferta='"+codigooferta+"' ")
_cnx.commit()
if self.debug: print "update (OK!)"
return True,"La oferta ha sido actualizada con éxito."
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "NO Insert Error %s" % (exceptionValue)
return False, "%s" % (exceptionValue)
示例14: update_order
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def update_order(self,numeroorden=None,codigoorden=None,responsable=None,estado=None,observaciones=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if not self.seek_NumOrder(numeroorden)[0]:
return False,"La orden de trabajo que desea actualizar no existe comuniquese con el administrador."
self.response= _cnx.no_single_query("UPDATE ordendetrabajo set responsable='"+responsable+"',estado='"+estado+"',observaciones='"+observaciones+"' WHERE codigoorden='"+codigoorden+"' ")
_cnx.commit()
if self.debug: print "update (OK!)"
return True, "La orden <b>'"+numeroorden+"'</b> ha sido <b>Actualizada</b> con exito <br/> <b><a href='/setorderservice'>Ver lista</a></b> "
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "NO Insert Error %s" % (exceptionValue)
return False, "%s" % (exceptionValue)
示例15: save_role
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import commit [as 别名]
def save_role(self,namerol=None,state=None,subsidiary=None,properties=None,description=None,roleowner=None):
"""Create a new rol
"""
if self.debug: print "Connect to database"
_cnx= Connection()
try:
if self.exists(namerol,subsidiary):
return False, "El perfil de usuario <b>"+namerol+"</b> que intenta crear ya existe"
self.response= _cnx.no_single_query("INSERT INTO ROLES (NOMBREROL,ESTADOROL,CODIGOSUCURSAL,PROPIEDADESROL,DESCRIPCIONROL,PROPIETARIOROL) VALUES ('"+namerol+"','"+state+"',(select codigosucursal from sucursal where sucursal.nombre='"+subsidiary+"'),'"+properties+"','"+description+"','"+roleowner+"')");
_cnx.commit()
if self.debug: print "Insert (OK!)"
return True, "El perfil de usuario <b>"+namerol+"</b> se guardo con exito"
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
if self.debug: print "NO Insert Error %s" % (exceptionValue)
return False, "%s" % (exceptionValue)