MCPcopy Create free account
hub / github.com/PyMySQL/PyMySQL / escape

Method escape

pymysql/connections.py:530–543  ·  view source on GitHub ↗

Escape whatever value is passed. Non-standard, for internal use; do not use this in your applications.

(self, obj, mapping=None)

Source from the content-addressed store, hash-verified

528 self._read_ok_packet()
529
530 def escape(self, obj, mapping=None) -> str:
531 """Escape whatever value is passed.
532
533 Non-standard, for internal use; do not use this in your applications.
534 """
535 if isinstance(obj, str):
536 return f"'{self._escape_string(obj)}'"
537
538 if isinstance(obj, (bytes, bytearray)):
539 return f"X'{obj.hex()}'"
540
541 if mapping is None:
542 mapping = self.encoders
543 return converters.escape_item(obj, self.encoding, mapping=mapping)
544
545 def literal(self, obj) -> str:
546 """Alias for escape().

Callers 9

_send_autocommit_modeMethod · 0.95
literalMethod · 0.95
callprocMethod · 0.80
test_escape_stringMethod · 0.80
test_escape_list_itemMethod · 0.80

Calls 1

_escape_stringMethod · 0.95