Returns the quoted, escaped string (e.g., "'a bird\'s feathers'") for database entry. Anything that is not a string (e.g., an integer) is converted to string. Booleans are converted to "0" and "1", None is converted to "null".
(self, value)
| 555 | self._connection.rollback() |
| 556 | |
| 557 | def escape(self, value): |
| 558 | """ Returns the quoted, escaped string (e.g., "'a bird\'s feathers'") for database entry. |
| 559 | Anything that is not a string (e.g., an integer) is converted to string. |
| 560 | Booleans are converted to "0" and "1", None is converted to "null". |
| 561 | """ |
| 562 | def quote(string): |
| 563 | # How to escape strings differs between database engines. |
| 564 | if self.type == MYSQL: |
| 565 | #return "'%s'" % self._connection.escape_string(string) # Doesn't like Unicode. |
| 566 | return "'%s'" % string.replace("'", "\\'") |
| 567 | if self.type == SQLITE: |
| 568 | return "'%s'" % string.replace("'", "''") |
| 569 | return _escape(value, quote) |
| 570 | |
| 571 | def binary(self, data): |
| 572 | """ Returns the string of binary data as a value that can be inserted in a BLOB field. |