title: OperationalError: attempt to write a readonly database in ubuntu server
body: <p>I'm running a FlaskApp using <code>mod_wsgi</code> and <code>apache2</code> on Ubuntu server. I tried running the flask app on <code>localhost</code> successfully and then deployed it on ubuntu server.</p>
  <p>But when i try to update database, its giving error:</p>
  <pre><code>Failed to update model. (OperationalError) attempt to write a readonly database u'UPDATE mysongs SET songurl=? WHERE songid.id = ?' (u'www.site.com/I_wanna_dance', 1)
  </code></pre>
  <p>Now i tried look for database file permission which is:</p>
  <pre><code>-rwxr-xr-x 1 www-data www-data 10240 Jul 14 15:35 /var/www/mywebsite/appfolder/appdata.db`
  </code></pre>
  <p>When i try changing permission to 777, 755, 644 etc. it shows another error: <code>unable to open database file</code> Although database file works fine with 644 permission on <code>localhost</code> but not on ubuntu server.</p>
  <p>Also i checked permission of directories and for <code>/var</code> <code>/var/www</code> <code>/var/www/mywebsite</code> <code>/var/www/mywebsite/appfolder</code> etc., all have <code>www-data:www-data</code> as its owner username and group.</p>
  <p>I tried googling and but no proper solution other than suggestion of changing file/dir permissions, which i have tried myself.</p>
  <p>Why can't it read/access the database file?</p>
  <p>Please suggest.</p>