Re: Python: Text file insert to MySQL

Discussion in 'Python' started by Gerhard Häring, Oct 6, 2009.

  1. 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
    Gerhard Häring, Oct 6, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JL
    Replies:
    0
    Views:
    1,134
  2. Replies:
    2
    Views:
    6,174
  3. Jeffrey H. Coffield
    Replies:
    1
    Views:
    1,829
  4. Roedy Green
    Replies:
    0
    Views:
    1,462
    Roedy Green
    Jul 23, 2009
  5. Gerhard Häring

    Re: Python: Text file insert to MySQL

    Gerhard Häring, Oct 7, 2009, in forum: Python
    Replies:
    0
    Views:
    441
    Gerhard Häring
    Oct 7, 2009
Loading...

Share This Page