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));
1
INSERT INTO MY_TABLE id,path values(23,'c:\\windows\\system')