<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="<a href="http://www.freesql.org">www.freesql.org</a>",<br>user="edhotchkiss",<br>port=3306,<br>passwd="test1",<br> db="links")
<br><br>cursor = conn.cursor()<br>stmt = "DROP TABLE IF EXISTS links"<br>cursor.execute(stmt)<br>stmt = """CREATE TABLE links (<br> ID INT NOT NULL,<br> Name TEXT,<br> URL LONGTEXT,<br> Category LONGTEXT,
<br> primary key (ID)<br>)"""<br>cursor.execute(stmt)<br><br><br>arr=[]<br>inp = open ("sites1.txt","r")<br>#read line into array<br>for line in inp.readlines():<br> links = map(str, line.split
(","))<br> arr.append(links)<br> cursor.execute ("""<br>INSERT INTO links (Name, URL, category)<br> VALUES (%s, %s, %s)""" % tuple(links[0:3])<br> )<br>cursor.close()<br>conn.close
()<br><br><br>--<br>edward hotchkiss<br><br>