I am having difficulties inserting a string in my mysql database when the string contains '
here is the string and the code, I don't want to get rid of this character or replace it with "
String
I heard Allah's Messenger saying, "The reward of deeds depends upon the intentions and every person will get the reward according to what he has intended. So whoever emigrated for worldly benefits or for a woman to marry, his emigration was for what he emigrated for."
CODE
#! /usr/bin/env python
from bs4 import BeautifulSoup
import urllib2
import lxml
from lxml import etree
import mysql.connector
import re
import time
# =============DATABASE SETTINGS===================
mysql_host = '192.168.0.15'
mysql_localhost_user = 'admin'
mysql_localhost_password = 'xxxxxxx'
mysql_localhost_database = 'prayertime'
cnx = mysql.connector.connect(host=mysql_host, user=mysql_localhost_user, password=mysql_localhost_password, database=mysql_localhost_database)
topic = "Revelation"
arabic_hadith = "test"
english_hadith = "I heard Allah's Messenger saying, The reward of deeds depends upon the intentions and every person will get the reward according to what he has intended. So whoever emigrated for worldly benefits or for a woman to marry, his emigration was for what he emigrated for."
cursor = cnx.cursor()
cursor.execute("INSERT INTO " + mysql_localhost_database +".hadith" + " (hadith,translated_hadith,topic)" + " VALUES ('" + arabic_hadith+ "', '" + english_hadith+ "' , '" + topic+ "')" )
cnx.commit()
cursor.close()
cnx.close()