Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 inserting data to mysql with python

Would anyone be able to help me out with the python code. I have been trying to write a code to read a value from .csv file and insert it into the mysql database. Unfortunately, I keep getting the error that syntax is incorrect.

This is the code I have written:
cur.execute("INSERT INTO Leashold_tb (leashold_or_not) VALUES (%(leashold_or_not,)s), ")

The error message I get is:
mysql.connector.errors.ProgrammingError: 1064 (42000): 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 '' at line 1

I have been looking into many guides online, but I just can not find the correct way.

Would anyone be able to help me out here?

horrible with sql syntax myself but maybe have a look at this

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  execute MySql function duende 0 72 Aug-04-2019, 08:20 AM
Last Post: duende
  How to return value from a stored procedure of a MySQL database? UtiliseIT 0 100 Jul-22-2019, 10:14 AM
Last Post: UtiliseIT
  [split] Automate the boring stuff, inserting commas in list srikanth 1 134 Jul-02-2019, 02:29 PM
Last Post: metulburr
  Trying to write an app to connect to a mysql DB gizmo 0 134 Jul-02-2019, 12:00 PM
Last Post: gizmo
  Inserting a variable name into xlabel myersluke 0 131 Jun-19-2019, 10:22 PM
Last Post: myersluke
  How to conver txt file data to python? yunglin 1 176 Jun-13-2019, 07:50 PM
Last Post: micseydel
  Mysql returning number of rows not data AkaAndrew123 4 392 Jun-10-2019, 02:31 PM
Last Post: AkaAndrew123
  MySQL executemany - Failed executing the operation; Could not process parameters josh_marchant 1 284 May-16-2019, 04:22 PM
Last Post: woooee
  Inserting csv values into SQL server vincentwebs 3 247 May-15-2019, 05:25 PM
Last Post: Larz60+
  Reading in MYSQL data as integer type Daveinthebigcity 2 216 May-13-2019, 11:30 AM
Last Post: Daveinthebigcity

Forum Jump:

Users browsing this thread: 2 Guest(s)