techwithtim / Flask-Blog-Tutorial

A blog application in python using Flask.
104 stars 68 forks source link

Problem with your SQLite table! #5

Open OriLev123 opened 3 years ago

OriLev123 commented 3 years ago

Hi Tim! The default argument of the column date should be a function, not the function response. You wrote: "default=func.now()" But you should write: "default=func.now" (pass the function as an argument…)

arnobt78 commented 7 months ago

Hi, I am having an error while running your final tutorial 5 while signing or login in, it looks like it can't create or identify any database! Can you please take a look, at where is the problem? Thanks in advance.

OperationalError sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user [SQL: SELECT user.id AS user_id, user.email AS user_email, user.username AS user_username, user.password AS user_password, user.date_created AS user_date_created FROM user WHERE user.email = ? LIMIT ? OFFSET ?] [parameters: ('arnob_t78@yahoo.com', 1, 0)] (Background on this error at: https://sqlalche.me/e/20/e3q8)

Traceback (most recent call last) File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1960, in _exec_single_context self.dialect.do_execute( ^ File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 924, in do_execute cursor.execute(statement, parameters) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The above exception was the direct cause of the following exception: File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 1488, in call return self.wsgi_app(environ, start_response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 1466, in wsgi_app response = self.handle_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 1463, in wsgi_app response = self.full_dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 872, in full_dispatch_request rv = self.handle_user_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 870, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 855, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/arnob_t78/myProjects/testWebApp/website/auth.py", line 38, in sign_up email_exists = User.query.filter_by(email=email).first() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2727, in first return self.limit(1)._iter().first() # type: ignore ^^^^^^^^^^^^^^^^^^^^^ File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2826, in _iter result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2306, in execute return self._execute_internal(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2191, in _execute_internal result: Result[Any] = compile_state_cls.orm_execute_statement(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 293, in orm_execute_statement result = conn.execute(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1408, in execute return meth(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 513, in _execute_on_connection return connection._execute_clauseelement(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1630, in _execute_clauseelement ret = self._execute_context(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1839, in _execute_context return self._exec_single_context(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1979, in _exec_single_context self._handle_dbapi_exception( ^ File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2335, in _handle_dbapi_exception raise sqlalchemy_exception.with_traceback(exc_info[2]) from e ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1960, in _exec_single_context self.dialect.do_execute( ^ File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 924, in do_execute cursor.execute(statement, parameters) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user [SQL: SELECT user.id AS user_id, user.email AS user_email, user.username AS user_username, user.password AS user_password, user.date_created AS user_date_created FROM user WHERE user.email = ? LIMIT ? OFFSET ?] [parameters: ('arnob_t78@yahoo.com', 1, 0)] (Background on this error at: https://sqlalche.me/e/20/e3q8)