本文整理汇总了Python中db_class.Connection.single_query方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.single_query方法的具体用法?Python Connection.single_query怎么用?Python Connection.single_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db_class.Connection
的用法示例。
在下文中一共展示了Connection.single_query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: entry
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def entry(self, username=None, password=None):
"""A new User with username and password try login
Parameters:
username: a not null email address or
a possibly-null-not string uniquely
identifying the specified user
password: a not null key the specified user
Return:
True: wheather username exits and return a
JSON Object with user map from database
False: wheather username NOT exits and return
None Object
"""
self.username= username #user name to entry
self.password= password #password to entry
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "Query by user "+self.username+" with pass "+self.password+" "
if username == "admin":
self.response= _cnx.single_query("SELECT * FROM usuarios,roles where usuario='"+self.username+"' and contraseniausuario='"+self.password+"' and idrol=roldeusuario limit 1")
else:
self.response= _cnx.single_query("SELECT * FROM usuarios,roles,sucursal where usuario='"+self.username+"' and contraseniausuario='"+self.password+"' and idrol=roldeusuario and roles.codigosucursal = sucursal.codigosucursal limit 1")
if (self.response is not None and len(self.response) > 0):
if self.debug: print "User "+self.username+" FOUND"
return True,self.response[0] #return pair True, JSON
else:
if self.debug: print "User "+self.username+" NO FOUND"
return False,None #return Flase, None
示例2: all_users
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def all_users(self,subsidiary=None):
"""
All user in database system
Parameters:
None
Return:
True: wheather exits users and return a
JSON Object with user map from database
False: wheather NOT exits user and return
None Object
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query all users"
self.response= _cnx.single_query("SELECT * FROM usuarios where codigosucursal "+subsidiary+" ")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"user found"
#Si no es nulo y la longitud de la consulta es mayor que 1
return True,self.response
else:
if self.debug: print "NOT found users"
#return Flase, None
return False,None
示例3: seek_quotation
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def seek_quotation(self,numerocotizacion=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query "+numerocotizacion+" quotations"
self.response= _cnx.single_query("SELECT * FROM cotizacion where numerocotizacion = '"+numerocotizacion+"' ")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"quotation found"
return True,self.response
else:
if self.debug: print "NOT found quotations"
return False,None
示例4: exist_offer
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def exist_offer(self,codigovehiculo=None,codigorepuesto=None,tipooferta=None,valoroferta=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "Buscando ofertas"
self.response= _cnx.single_query("SELECT * FROM ofertas WHERE tipooferta='"+tipooferta+"' AND codigovehiculo='"+codigovehiculo+"' AND codigorepuesto ='"+codigorepuesto+"' AND valoroferta ='"+valoroferta+"'" )
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"ofertas encontradas"
return True
else:
if self.debug: print "No hay ofertas"
return False
示例5: all_offerspublic
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def all_offerspublic(self,subsidiary=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query all offers"
self.response= _cnx.single_query("SELECT * FROM ofertas WHERE estado ='PUBLICA' AND codigosucursal "+subsidiary+" ORDER BY codigooferta DESC")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"ofertas encontradas"
return True,self.response
else:
if self.debug: print "No hay ofertas"
return False,None
示例6: exist_offerbyId
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def exist_offerbyId(self,codigooferta):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query all offers"
self.response= _cnx.single_query("SELECT * FROM ofertas WHERE codigooferta='"+codigooferta+"'")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"ofertas encontradas"
return True
else:
if self.debug: print "No hay ofertas"
return False
示例7: seek_offerbyuid
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def seek_offerbyuid(self,uuid=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query offer uuid= "+uuid+""
self.response= _cnx.single_query("SELECT * FROM ofertas WHERE uuid = '"+uuid+"' ")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"offers found --"
return True,self.response
else:
if self.debug: print "No offers found"
return False,None
示例8: all_quotations
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def all_quotations(self,codigo_sucursal=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query all articles"
self.response = _cnx.single_query("SELECT * FROM cotizacion where codigosucursal "+codigo_sucursal+" ")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"articles found"
return True,self.response
else:
if self.debug: print "NOT found articles"
#return Flase, None
return False,None
示例9: all_sales
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def all_sales(self,codigo_sucursal=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query all sales"
self.response = _cnx.single_query("SELECT * FROM venta,cliente where venta.codigosucursal "+codigo_sucursal+" and venta.codigocliente = cliente.codigocliente")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"sales found"
return True,self.response
else:
if self.debug: print "NOT found sales"
#return Flase, None
return False,None
示例10: seek_inventory_byId
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def seek_inventory_byId(self,identifier=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query inventory with id = "+str(identifier)+" "
self.response= _cnx.single_query("SELECT * FROM inventario where codigocarro = '"+str(identifier)+"' or codigorepuesto = '"+str(identifier)+"' ")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"inventory found"
#Si no es nulo y la longitud de la consulta es mayor que 1
return True,self.response
else:
if self.debug: print "NOT found inventory"
#return Flase, None
return False,None
示例11: seek_inventory_bySubsidiary
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def seek_inventory_bySubsidiary(self,codigo_sucursal=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query "+str(codigo_sucursal)+" inventory"
self.response= _cnx.single_query("SELECT * FROM inventario where codigo_sucursal = '"+str(codigo_sucursal)+"' ")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"inventory found"
#Si no es nulo y la longitud de la consulta es mayor que 1
return True,self.response
else:
if self.debug: print "NOT found inventory"
#return Flase, None
return False,None
示例12: exist_vehicle
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def exist_vehicle(self,marca = None,linea = None,modelo = None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "existe el vehiculo con marca <b>"+marca+"</b> linea"+linea+"<b> y modelo <b>"+modelo+"</b>"
self.response= _cnx.single_query("SELECT * FROM vehiculo where marca = '"+marca+"' and modelo='"+modelo+"' and linea='"+linea+"' ")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"car found"
#Si no es nulo y la longitud de la consulta es mayor que 1
return True
else:
if self.debug: print "No hay vehiculo con marca <b>"+marca+"</b> linea"+linea+"<b> y modelo <b>"+modelo+"</b>"
#return Flase, None
return False
示例13: seek_vehicle_byImportNumber
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def seek_vehicle_byImportNumber(self,numero_importacion=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query "+numero_importacion+" car"
self.response= _cnx.single_query("SELECT * FROM vehiculo where numero_importacion = '"+numero_importacion+"' ")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"car found"
#Si no es nulo y la longitud de la consulta es mayor que 1
return True,self.response
else:
if self.debug: print "NOT found cars"
#return Flase, None
return False,None
示例14: seek_vehicle_byImagen
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def seek_vehicle_byImagen(self,identifier=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query car with id = "+str(identifier)+" "
self.response= _cnx.single_query("SELECT * FROM vehiculo where imagenes = '"+str(identifier)+"' ")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"car found"
#Si no es nulo y la longitud de la consulta es mayor que 1
return True,self.response
else:
if self.debug: print "NOT found cars"
#return Flase, None
return False,None
示例15: seek_subsidiary_byId
# 需要导入模块: from db_class import Connection [as 别名]
# 或者: from db_class.Connection import single_query [as 别名]
def seek_subsidiary_byId(self,identifier=None):
"""
"""
if self.debug: print "Connect to database"
_cnx= Connection()
if self.debug: print "query subsidiary with id = "+str(identifier)+" "
self.response= _cnx.single_query("SELECT * FROM sucursal where codigosucursal = '"+str(identifier)+"' ")
if (self.response is not None and len(self.response) > 0):
if self.debug: print len(self.response),"subsidiary found"
#Si no es nulo y la longitud de la consulta es mayor que 1
return True,self.response
else:
if self.debug: print "NOT found subsidiaries"
#return Flase, None
return False,None