Guest User

Untitled

a guest
Mar 10th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. select id from tbl005_league_club where name = 'PERFUMERIAS AVENIDA'
  2.  
  3. self.connection = pymysql.connect(host = DDBB.DDBB_HOST,
  4. user = DDBB.DDBB_USER,
  5. password = DDBB.DDBB_PSWD,
  6. db = DDBB.DDBB_NAME,
  7. charset = DDBB.DDBB_CHARSET,
  8. cursorclass=pymysql.cursors.DictCursor)
  9.  
  10. def query(self, sql, data):
  11. """Método que devuelve un objeto ResultData con el resultado de la consulta"""
  12. try:
  13. with self.connection.cursor() as cursor:
  14. totalRows = cursor.execute(sql, data)
  15. print("Total Rows: " + str(totalRows))
  16. print("Ultima query: " + cursor.mogrify(sql, data))
  17. data = cursor.fetchall()
  18. if totalRows > 0:
  19. result = ResultData(RESULT.RESULT_OK, data, totalRows)
  20. else:
  21. result = ResultData(RESULT.RESULT_OK, None, totalRows)
  22. return result
  23. except Exception as error:
  24. raise DDBBException("DAOMySQL", "query", error,
  25. "Se ha producido un error al hacer la consulta")
Add Comment
Please, Sign In to add comment