How to solve no such table: user in Heroku application?
Question: I have deploy the application but its showing me an internal server error .
the same application I have run on localhost but now I am trying to run
through heroku but its not giving me an output. the application is there on
the link given below <http://flask.pocoo.org/>

    
    
    File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    2015-11-26T06:31:28.153486+00:00 app[web.1]:     reraise(exc_type, exc_value, tb)
    2015-11-26T06:31:28.153487+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    2015-11-26T06:31:28.153488+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    2015-11-26T06:31:28.153489+00:00 app[web.1]:     return self.view_functions[rule.endpoint](**req.view_args)
    2015-11-26T06:31:28.153491+00:00 app[web.1]:     [username], one=True)
    2015-11-26T06:31:28.153491+00:00 app[web.1]:   File "/app/minitwit.py", line 63, in query_db
    2015-11-26T06:31:28.153493+00:00 app[web.1]: OperationalError: no such table: user
    2015-11-26T06:31:28.153486+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    2015-11-26T06:31:28.153486+00:00 app[web.1]:     reraise(exc_type, exc_value, tb)
    2015-11-26T06:31:28.153487+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    2015-11-26T06:31:28.153488+00:00 app[web.1]:     rv = self.dispatch_request()
    2015-11-26T06:31:28.153490+00:00 app[web.1]:   File "/app/minitwit.py", line 125, in user_timeline
    2015-11-26T06:31:28.153489+00:00 app[web.1]:     return self.view_functions[rule.endpoint](**req.view_args)
    2015-11-26T06:31:28.153491+00:00 app[web.1]:     [username], one=True)
    2015-11-26T06:31:28.153491+00:00 app[web.1]:   File "/app/minitwit.py", line 63, in query_db
    2015-11-26T06:31:28.153492+00:00 app[web.1]:     cur = get_db().execute(query, args)
    2015-11-26T06:31:28.153493+00:00 app[web.1]: OperationalError: no such table: user
    2015-11-26T06:31:28.153486+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    2015-11-26T06:31:28.153486+00:00 app[web.1]:     reraise(exc_type, exc_value, tb)
    2015-11-26T06:31:28.153487+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    2015-11-26T06:31:28.153490+00:00 app[web.1]:   File "/app/minitwit.py", line 125, in user_timeline
    2015-11-26T06:31:28.153491+00:00 app[web.1]:     [username], one=True)
    2015-11-26T06:31:28.153491+00:00 app[web.1]:   File "/app/minitwit.py", line 63, in query_db
    2015-11-26T06:31:28.153486+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    2015-11-26T06:31:28.153488+00:00 app[web.1]:     rv = self.dispatch_request()
    2015-11-26T06:31:28.153488+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    2015-11-26T06:31:28.153486+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    2015-11-26T06:31:28.153486+00:00 app[web.1]:     reraise(exc_type, exc_value, tb)
    2015-11-26T06:31:28.153487+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    2015-11-26T06:31:28.153488+00:00 app[web.1]:     rv = self.dispatch_request()
    2015-11-26T06:31:28.153490+00:00 app[web.1]:   File "/app/minitwit.py", line 125, in user_timeline
    2015-11-26T06:31:28.153491+00:00 app[web.1]:   File "/app/minitwit.py", line 63, in query_db
    2015-11-26T06:31:28.153492+00:00 app[web.1]:     cur = get_db().execute(query, args)
    2015-11-26T06:41:02.282478+00:00 heroku[router]: at=info method=GET path="/public" host=minitwittest.herokuapp.com request_id=a93d6057-f7de-4a9b-876c-a13372c31cbc fwd="103.5.187.166" dyno=web.1 connect=1ms service=8ms status=500 bytes=244
    2015-11-26T06:41:02.272442+00:00 app[web.1]: [2015-11-26 06:41:02 +0000] [9] [ERROR] Error handling request /public
    2015-11-26T06:41:02.272445+00:00 app[web.1]: Traceback (most recent call last):
    2015-11-26T06:41:02.272447+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 130, in handle
    2015-11-26T06:41:02.272448+00:00 app[web.1]:     self.handle_request(listener, req, client, addr)
    2015-11-26T06:41:02.272448+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 171, in handle_request
    2015-11-26T06:41:02.272452+00:00 app[web.1]:     return self.wsgi_app(environ, start_response)
    2015-11-26T06:41:02.272454+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    2015-11-26T06:41:02.272456+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    2015-11-26T06:41:02.272457+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    2015-11-26T06:41:02.272458+00:00 app[web.1]:     rv = self.handle_user_exception(e)
    2015-11-26T06:41:02.272459+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    2015-11-26T06:41:02.272460+00:00 app[web.1]:     reraise(exc_type, exc_value, tb)
    2015-11-26T06:41:02.272461+00:00 app[web.1]:     rv = self.dispatch_request()
    2015-11-26T06:41:02.272462+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    2015-11-26T06:41:02.272469+00:00 app[web.1]:     order by message.pub_date desc limit ?''', [PER_PAGE]))
    2015-11-26T06:41:02.272470+00:00 app[web.1]:     cur = get_db().execute(query, args)
    2015-11-26T06:41:02.811154+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=minitwittest.herokuapp.com request_id=3b9d3742-4940-493a-ba29-579865ca6b40 fwd="103.5.187.166" dyno=web.1 connect=2ms service=5ms status=500 bytes=244
    2015-11-26T06:41:02.801367+00:00 app[web.1]: [2015-11-26 06:41:02 +0000] [10] [ERROR] Error handling request /favicon.ico
    2015-11-26T06:41:02.801371+00:00 app[web.1]: Traceback (most recent call last):
    2015-11-26T06:41:02.801372+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 130, in handle
    2015-11-26T06:41:02.801373+00:00 app[web.1]:     self.handle_request(listener, req, client, addr)
    2015-11-26T06:41:02.801374+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 171, in handle_request
    2015-11-26T06:41:02.801375+00:00 app[web.1]:     respiter = self.wsgi(environ, resp.start_response)
    2015-11-26T06:41:02.801376+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    2015-11-26T06:41:02.801377+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    2015-11-26T06:41:02.801378+00:00 app[web.1]:     response = self.make_response(self.handle_exception(e))
    2015-11-26T06:41:02.801379+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    2015-11-26T06:41:02.801380+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    2015-11-26T06:41:02.801382+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    2015-11-26T06:41:02.801384+00:00 app[web.1]:     rv = self.handle_user_exception(e)
    2015-11-26T06:41:02.801384+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    2015-11-26T06:41:02.801385+00:00 app[web.1]:     reraise(exc_type, exc_value, tb)
    2015-11-26T06:41:02.801386+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    2015-11-26T06:41:02.801386+00:00 app[web.1]:     rv = self.dispatch_request()
    2015-11-26T06:41:02.801387+00:00 app[web.1]:     return self.view_functions[rule.endpoint](**req.view_args)
    2015-11-26T06:41:02.801388+00:00 app[web.1]:   File "/app/minitwit.py", line 125, in user_timeline
    2015-11-26T06:41:02.801389+00:00 app[web.1]:     [username], one=True)
    2015-11-26T06:41:02.801389+00:00 app[web.1]:   File "/app/minitwit.py", line 63, in query_db
    2015-11-26T06:41:02.801390+00:00 app[web.1]:     cur = get_db().execute(query, args)
    2015-11-26T06:41:02.801391+00:00 app[web.1]: OperationalError: no such table: user
    2015-11-26T06:41:02.801384+00:00 app[web.1]:     rv = self.handle_user_exception(e)
    2015-11-26T06:41:02.801385+00:00 app[web.1]:     reraise(exc_type, exc_value, tb)
    2015-11-26T06:41:02.801387+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    2015-11-26T06:41:02.801388+00:00 app[web.1]:   File "/app/minitwit.py", line 125, in user_timeline
    2015-11-26T06:41:02.801387+00:00 app[web.1]:     return self.view_functions[rule.endpoint](**req.view_args)
    2015-11-26T06:41:02.801389+00:00 app[web.1]:     [username], one=True)
    2015-11-26T06:41:02.801391+00:00 app[web.1]: OperationalError: no such table: user
    2015-11-26T06:41:02.801384+00:00 app[web.1]:     rv = self.handle_user_exception(e)
    2015-11-26T06:41:02.801384+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    2015-11-26T06:41:02.801385+00:00 app[web.1]:     reraise(exc_type, exc_value, tb)
    2015-11-26T06:41:02.801387+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    2015-11-26T06:41:02.801386+00:00 app[web.1]:     rv = self.dispatch_request()
    2015-11-26T06:41:02.801387+00:00 app[web.1]:     return self.view_functions[rule.endpoint](**req.view_args)
    2015-11-26T06:41:02.801389+00:00 app[web.1]:   File "/app/minitwit.py", line 63, in query_db
    2015-11-26T06:41:02.801390+00:00 app[web.1]:     cur = get_db().execute(query, args)
    2015-11-26T06:41:02.801391+00:00 app[web.1]: OperationalError: no such table: user
    


Answer: I assume you are using `Flask-SQLAlchemy` In that case you have to create
database table first. To do that you have to enter into `heroku run python`
and `from app import db` and `db.create_all()`.

