Python Forum

Full Version: inserting data to mysql with python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

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?

Thanks,
justin_py
horrible with sql syntax myself but maybe have a look at this
https://www.w3schools.com/sql/sql_insert.asp