That was great ! Now I am able to insert the values from the file. <br><br>Somehow I am not able to update a specific field with all the vaues in the file. For eg:<br><br>Before the update my table contents are:<br>+-------+-------+<br>
| first | last  |<br>+-------+-------+<br>| Sara  | Jones |<br>| Terry | Burns |<br>| Filiz | Khan  |<br>+-------+-------+<br><br>When I do the update using the following code,<br>-------------------------------------------------------------------------------------------------------------------------------------------<br>
import MySQLdb, csv, sys<br>conn = MySQLdb.connect (host = "localhost",user = "usr", passwd = "pass",db = "db")<br>c = conn.cursor()<br>csv_data=csv.reader(file("b.txt"))<br>
for row in csv_data:<br>    print row<br>    c.execute("UPDATE a SET last = %s", row)<br>#c.commit()<br>c.close()<br>---------------------------------------------------------------------------------------------------------------------------------------------<br>
<br>The table contents get updated with the last content of the input file . for eg <br>+-------+------+<br>| first | last |<br>+-------+------+<br>| Sara  | c    |<br>| Terry | c    |<br>| Filiz | c    |<br>+-------+------+<br>
<br>the contents of the  b.txt file:<br><br>a<br>b<br>c<br><br>Any kind of help would be greatly appreciated.<br><br>James<br><br><div class="gmail_quote">On Tue, Oct 6, 2009 at 9:33 PM, Gerhard Häring <span dir="ltr"><<a href="mailto:gh@ghaering.de">gh@ghaering.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">Schedule wrote:<br>
> Hello,<br>
><br>
> I am currenty using MySQL 5.1 community server and trying to import the<br>
> data of the comma delimited text file into the table using python 2.6<br>
> scripts. I have installed Mysqldb 1.2.2.<br>
><br>
> follwoing is my script:<br>
</div>> [...]<br>
>    7.<br>
<div class="im">>       c.execute("INSERT INTO a (first, last) VALUES (%s, %s), row")<br>
</div>> [...]<br>
<div class="im">> When I execute the statement I get the following error:<br>
> ------------------------------------------------------------------------------------<br>
</div>> [...]<br>
<div class="im">> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your<br>
> SQL syntax; check the manual tha<br>
> t corresponds to your MySQL server version for the right syntax to use<br>
> near '%s, %s), row' at line 1")<br>
<br>
</div>You misplaced the closing quote.<br>
<br>
wrong:   c.execute("INSERT INTO a (first, last) VALUES (%s, %s), row")<br>
correct: c.execute("INSERT INTO a (first, last) VALUES (%s, %s)", row)<br>
<br>
<br>
-- Gerhard<br>
<font color="#888888"><br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>