0

how to insert a whole sentence like (ex: text, plus comma,...) into one column?

here's my code :

cursor.execute( "INSERT INTO company(company_name, company_information, company_location, company_phone_number, comp_web_site,photo) VALUES ('{}','{}', '{}', '{}', '{}',{})".format(
                company_name, company_information, company_location, phone_number, web_site,image, 'NOW()'))

here's when i run the code

MySQLdb._exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Etudes Techniques Bâtiment, G.e.t.b. Ingénierie','\nGETB Engineering est un ...' at line 1")

Belas
  • 63
  • 6
  • what happens when you run your code? – askman Mar 19 '22 at 16:00
  • MySQLdb._exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Etudes Techniques Bâtiment, G.e.t.b. Ingénierie','\nGETB Engineering est un ...' at line 1") – Belas Mar 19 '22 at 16:04
  • 1
    You have one or more single quotes in your string. Instead of using string formatting, use parameter substitution as shown in the linked duplicate so that values are properly escaped. – snakecharmerb Mar 19 '22 at 16:12
  • i fixed it, used "{}" instead of '{}', thanks for replying – Belas Mar 19 '22 at 19:37

0 Answers0