I am using python to save a blogdata as an sql file . 

```
str = "INSERT INTO TABLENAME (id,name,con) VALUES ('%d','%s','%s')" %(id,nam,con)

```

Here, "con" refers to the content which contains all kinds of things like single quotes , double quotes and others . So the file became like this : 

```
INSERT INTO TABLENAME (id,name,con) VALUES('1','first','Hi I'm XXX . "435"  'sdfsd' ')

```

Please observer last part of above line, as it contains different quotes, the sql file will not be executed if i use the above format . What is the solution for this ? Will provide more information if necessary . 

Thanks