Flask app gives a “ 'NoneType' object has no attribute 'drivername' ” error

筅森魡賤 提交于 2021-02-10 14:20:01

问题


I got a VPS and I wanted to host my flask app there. I followed DigitalOcean's tutorial on "How To Serve Flask Applications with Gunicorn and Nginx on Ubuntu 18.04" (I didnt get the VPS from DO) and everything worked fine with the example app... when I tried to replace the files with my app's files and host the app again I get a 500 error. The 500 error doesnt appear everywhere. It comes up where my .db file is envoled like where I have posts or users etc.. Everything else loads up fine. The layout.html, footer, nav, static files and all that is there.

I already tried rebooting the server, checking env vars reloading nginx etc.. but nothing works.

When I run sudo systemctl status appname on terminal I get the following message

gunicorn[971]:     return self.get_engine()
gunicorn[971]:   File "/home/apost/atapazar/atapazarvenv/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 
gunicorn[971]:     return connector.get_engine()
gunicorn[971]:   File "/home/apost/atapazar/atapazarvenv/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 
gunicorn[971]:     options = self.get_options(sa_url, echo)
gunicorn[971]:   File "/home/apost/atapazar/atapazarvenv/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 
gunicorn[971]:     self._sa.apply_driver_hacks(self._app, sa_url, options)
gunicorn[971]:   File "/home/apost/atapazar/atapazarvenv/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 
gunicorn[971]:     if sa_url.drivername.startswith('mysql'):
gunicorn[971]: AttributeError: 'NoneType' object has no attribute 'drivername'

I'm assuming it's a probelm with SQLite. The site should load the .html files that contain .db info.

Edit: Already checked the other question's here on Stack and even looked on Github but didnt find a solution. Also when I run the app on my local machine the probelm doesnt come up.

来源:https://stackoverflow.com/questions/56097919/flask-app-gives-a-nonetype-object-has-no-attribute-drivername-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!