<br>Ok. I am trying to read a csv file with three strings separated by commas.<br>I am trying to insert them into a MySQL DB online.<br>MySQLdb is installed, no problems.<br><br>I think that I am having some kind of error with my csv going into the
<br>fields and being broken apart correctly. Can someone please help? I<br>attached the code below, it does work with that SQL server also if you<br>want to try and run it. Thanks in advance ..<br><br>-----<br><br># Script to add links from a comma deliminated file to a MySQL database
<br># 9/16/05<br><br>import MySQLdb<br><br>conn=MySQLdb.connect( host=&quot;<a href="http://www.freesql.org">www.freesql.org</a>&quot;,<br>user=&quot;edhotchkiss&quot;,<br>port=3306,<br>passwd=&quot;test1&quot;,<br>&nbsp;&nbsp; db=&quot;links&quot;)
<br><br>cursor = conn.cursor()<br>stmt = &quot;DROP TABLE IF EXISTS links&quot;<br>cursor.execute(stmt)<br>stmt = &quot;&quot;&quot;CREATE TABLE links (<br>&nbsp;&nbsp;ID INT NOT NULL,<br>&nbsp;&nbsp;Name TEXT,<br>&nbsp;&nbsp;URL LONGTEXT,<br>&nbsp;&nbsp;Category LONGTEXT,
<br>&nbsp;&nbsp;primary key (ID)<br>)&quot;&quot;&quot;<br>cursor.execute(stmt)<br><br><br>arr=[]<br>inp = open (&quot;sites1.txt&quot;,&quot;r&quot;)<br>#read line into array<br>for line in inp.readlines():<br>&nbsp;&nbsp;links = map(str, line.split
(&quot;,&quot;))<br>&nbsp;&nbsp;arr.append(links)<br>&nbsp;&nbsp;cursor.execute (&quot;&quot;&quot;<br>INSERT INTO links (Name, URL, category)<br>&nbsp;&nbsp;VALUES (%s, %s, %s)&quot;&quot;&quot; % tuple(links[0:3])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>cursor.close()<br>conn.close
()<br><br><br>--<br>edward hotchkiss<br><br>