Internal Server error: using python script with sqlite + mod_wsgi in apache
Question: This is my code example.

    
    
    import sqlite3
    
    def application(environ, start_response):
    
     output = "<p> LOG</p>"
    
     db = sqlite3.connect('/root/example.db')
     db.row_factory = sqlite3.Row
     cursor = db.cursor()
     cursor.execute('''SELECT id, message,date FROM table''')
     for row in cursor:
      print('{0} : {1}, {2}'.format(row['id'], row['message'], row['date']))
     db.close()
    
    start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
    return output
    

I get Internal Server Error.

How would solve the problem?


Answer: Since you webserver (hopefully) doesn't run as the `root`-User, placing your
database in the `/root` directory will not work.

You habe to put the database in a directory that is writable by your webserver
(as it looks to me, that would be `/var/www` for you).

And just to prevent further privilege problems, the database file needs to be
readable and writable by the webserver as well. On Ubuntu/Debian systems, this
can be done with

    
    
    chown www-data:www-data /var/www/example.db
    

