Python: Text file insert to MySQL
Gerhard Häring
gh at ghaering.de
Tue Oct 6 15:33:18 EDT 2009
Schedule wrote:
> Hello,
>
> I am currenty using MySQL 5.1 community server and trying to import the
> data of the comma delimited text file into the table using python 2.6
> scripts. I have installed Mysqldb 1.2.2.
>
> follwoing is my script:
> [...]
> 7.
> c.execute("INSERT INTO a (first, last) VALUES (%s, %s), row")
> [...]
> When I execute the statement I get the following error:
> ------------------------------------------------------------------------------------
> [...]
> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your
> SQL syntax; check the manual tha
> t corresponds to your MySQL server version for the right syntax to use
> near '%s, %s), row' at line 1")
You misplaced the closing quote.
wrong: c.execute("INSERT INTO a (first, last) VALUES (%s, %s), row")
correct: c.execute("INSERT INTO a (first, last) VALUES (%s, %s)", row)
-- Gerhard
More information about the Python-list
mailing list