title: How to export MYSQLdb table to CSV on Debian?
body: <p>I want to export MYSQLdb tables into .csv format.</p>
  
  <p>I tried this:</p>
  
  <pre><code>connection = MySQLdb.connect(host='localhost',
      user='***',
      passwd='***',
      db='database1',
      use_unicode=True,
      charset="utf8")
  cursor = connection.cursor()
  query = """ select * 
  from example_table1
  into outfile 'MYFOLDER'
  fields terminated by ';'
  enclosed by '"'
  lines terminated by '';
  """
  cursor.execute(query)
  connection.commit()
  cursor.close()
  </code></pre>
  
  <p>I get this error message:</p>
  
  <pre><code>Traceback (most recent call last):
    File "mysql_export_to_csv.py", line 46, in &lt;module&gt;
      cursor.execute(query)
    File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 226, in execute
      self.errorhandler(self, exc, value)
    File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
      raise errorvalue
  _mysql_exceptions.InternalError: (1, 'Can\'t create/write to file \'/usr/src/Python-2.7.13/output.csv\' (Errcode: 30 "Read-only file system")')
  </code></pre>
  
  <p>What is the problem in this code? Why  I can't export it to .csv?</p>