[ create a new paste ] login | about

Link: http://codepad.org/7mjbwKBf    [ raw code | output | fork ]

Python, pasted on Sep 26:
1
2
3
4
5
6
7
def addslashes(s):
    dict = {"\0":"\\\0", "\\":"\\\\"}  #add more here
    return ''.join(dict.get(x,x) for x in s)

query = "INSERT INTO MY_TABLE id,path values(23,'c:\windows\system\')";

print(addslashes(query));


Output:
1
INSERT INTO MY_TABLE id,path values(23,'c:\\windows\\system')


Create a new paste based on this one


Comments: