Escape whatever value is passed. Non-standard, for internal use; do not use this in your applications.
(self, obj, mapping=None)
| 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(). |