python - Flask: OperationalError: unable to open database file -


i having immense difficulties attempting flask application's database working. following sample tutorial flask , deploying site on apache server through amazon ec2 instance. have no difficulties accessing site, whenever try post database 500 internal server error. checking error.log shows:

[wed sep 13 19:37:47.713249 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492] [2017-09-13 19:37:47,712] error in app: exception on /add [post], referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713291 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492] traceback (most recent call last):, referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713294 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]   file "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1982, in wsgi_app, referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713296 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]     response = self.full_dispatch_request(), referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713299 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]   file "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1614, in full_dispatch_request, referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713301 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]     rv = self.handle_user_exception(e), referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713304 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]   file "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1517, in handle_user_exception, referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713306 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]     reraise(exc_type, exc_value, tb), referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713308 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]   file "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1612, in full_dispatch_request, referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713310 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]     rv = self.dispatch_request(), referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713312 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]   file "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1598, in dispatch_request, referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713314 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]     return self.view_functions[rule.endpoint](**req.view_args), referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713330 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]   file "/var/www/flaskapp/flaskapp/flaskapp.py", line 76, in add_entry, referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713333 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492]     [request.form['title'], request.form['text']]), referer: http://www.zachflask.tk/ [wed sep 13 19:37:47.713334 2017] [wsgi:error] [pid 27587] [client 209.54.86.83:50492] operationalerror: unable open database file, referer: http://www.zachflask.tk/ 

i thought may have file permissions, chmod 777 flaskapp.db without outcomes.

zld6fd@vanadium:/var/www/flaskapp/flaskapp$ ls -la total 44 drwxr-xr-x 5 zld6fd zld6fd 4096 sep 13 19:45 . drwxr-xr-x 6 zld6fd zld6fd 4096 sep 13 19:37 .. -rwxrwxrwx 1 zld6fd zld6fd 3072 sep 13 19:18 flaskapp.db -rw-rw-r-- 1 zld6fd zld6fd 3194 sep 13 19:16 flaskapp.py -rw-rw-r-- 1 zld6fd zld6fd 3943 sep 13 19:16 flaskapp.pyc -rw-r--r-- 1 zld6fd zld6fd   26 sep 12 20:39 __init__.py -rw-r--r-- 1 zld6fd zld6fd  177 sep 12 21:25 __init__.pyc -rwxrwxrwx 1 zld6fd zld6fd  145 sep 12 21:33 schema.sql drwxr-xr-x 5 zld6fd zld6fd 4096 sep 12 22:14 static drwxr-xr-x 2 zld6fd zld6fd 4096 sep 13 00:34 templates drwxr-xr-x 7 zld6fd zld6fd 4096 sep 11 23:32 venv 

my flaskapp.py file contains following:

# import statements import os import sqlite3 flask import flask, request, session, g, redirect, url_for, abort, \         render_template, flash  # application instance app = flask(__name__) # create instance app.config.from_object(__name__) # load config file  # load default config , override config environment variable app.config.update(dict(         database='/var/www/flaskapp/flaskapp/flaskapp.db',         secret_key='development key',         username='admin',         password='password' )) 

and apache conf file is:

<virtualhost *:80>             servername zachflask.tk             serveradmin zld6fd@mail.missouri.edu              wsgidaemonprocess flaskapp user=zld6fd group=zld6fd threads=5             wsgiscriptalias / /var/www/flaskapp/flaskapp.wsgi             <directory /var/www/flaskapp/flaskapp>                     wsgiprocessgroup flaskapp                     wsgiapplicationgroup %{global}                     require granted             </directory>             alias /static /var/www/flaskapp/flaskapp/static             <directory /var/www/flaskapp/flaskapp/static/>                     require granted             </directory>             errorlog /var/www/flaskapp/logs/error.log             loglevel warn             customlog /var/www/flaskapp/logs/access.log combined </virtualhost> 

any appreciated.

the solution found @pvg suggested in comments. flaskapp.db had been set correct permissions, failed update permissions of directory within. moved flaskapp.db file new tmp/ folder , ran sudo chmod 777 tmp


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -