Revision 5142
Added by Aaron Marcuse-Kubitza about 12 years ago
strings.py | ||
---|---|---|
71 | 71 |
|
72 | 72 |
##### Escaping |
73 | 73 |
|
74 |
def esc_quotes(str_, quote='"', esc='\\', quote_esc=None): |
|
75 |
if quote_esc == None: quote_esc = esc+quote |
|
76 |
|
|
77 |
if esc != quote: str_ = str_.replace(esc, esc+esc) |
|
78 |
str_ = str_.replace(quote, quote_esc) |
|
79 |
return str_ |
|
80 |
|
|
74 | 81 |
def esc_for_mogrify(query): |
75 | 82 |
'''Escapes a query right before being passed to a mogrifying function.''' |
76 | 83 |
return query.replace('%', '%%') |
Also available in: Unified diff
strings.py: Added esc_quotes()