(self)
| 271 | def __init__(self, data, type=SQLITE): |
| 272 | self.data, self.type = str(hasattr(data, "read") and data.read() or data), type |
| 273 | def escape(self): |
| 274 | if self.type == SQLITE: |
| 275 | return str(self.data.encode("string-escape")).replace("'","''") |
| 276 | if self.type == MYSQL: |
| 277 | return MySQLdb.escape_string(self.data) |
| 278 | |
| 279 | def _escape(value, quote=lambda string: "'%s'" % string.replace("'", "\\'")): |
| 280 | """ Returns the quoted, escaped string (e.g., "'a bird\'s feathers'") for database entry. |