title: Dumping CSV files to MySQL database using embedded query in python script
body: <p>I have a SQL query which opens up a csv file and dumps it in a table of a database. I am trying to dump multiple files at once using a python script to iterate among the files. I tried embedding the same SQL query inside the script, but it throws out an error.</p>
  
  <p>This is the script I have.</p>
  
  <pre><code>import csv
  import MySQLdb
  
  connection = MySQLdb.connect(host='localhost',
      user='root',
      passwd='password',
      db='some_db')
  
  
  cursor = connection.cursor()
  
  query = """ LOAD DATA INFILE 'c:\\example.csv' INTO TABLE new_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' Lines terminated by '\n' IGNORE 1 LINES """
  
  cursor.execute(query)
  
  conenction.commit()
  cursor.close()
  </code></pre>
  
  <p>And for some reason the python script looks up example.csv at a different location</p>
  
  <p>This is the error that is thrown out :</p>
  
  <pre><code>raise errorclass, errorvalue
  InternalError: (29, "File 'C:\\Documents and Settings\\All Users\\Application Data\\MySQL\\MySQL Server 5.5\\data\\example.csv' not found (Errcode: 2)")
  </code></pre>
  
  <p>Any help would be greatly appreciated. I am also searching on stackoverflow for help to dump the scv files into differnt tables of a database. Any ideas on  that?</p>