I have below MySQL statement with python but there is a single quote ' in one of the values hence I got below error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near L at line 1
The value to be inserted is Regal INT'L
How to escape or to correct the MySQL statement?
MySQL statement
def query(self, item):
return "INSERT INTO income_statement({columns}) VALUES ({values})".format(
columns=', '.join(item.keys()),
values=self.item_to_text(item)
)
def item_to_text(self, item):
return ', '.join("'" + str(v) + "'" for v in item.values()
)