import pymysql class db(): DB = "EBA_STOCK" USER = "root" PASSWORD = "howdoiturnthison" def __init__(self): self.conn = pymysql.connect(unix_socket='/var/run/mysqld/mysqld.sock', user=db.USER, passwd=db.PASSWORD, db=db.DB,cursorclass=pymysql.cursors.DictCursor) def client(self, _hash): cur = self.conn.cursor() cur.execute("SELECT id,nombre,apellido,hash FROM clientes where hash=%s", (_hash,)) res = cur.fetchall() if len(res) == 0: return None return res[0] def products(self, _id=None): ret=[] if _id is None: cur = self.conn.cursor() cur.execute("SELECT id,nombre,precio FROM productos where id between 1000 and 2999") for row in cur.fetchall(): row["cantidad"]=0 ret.append(row) else: pass return ret def pedido(self, pedido): return 0