Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: "no such table: user" when reproducing Basic SQLAlchemy Application with session quickstart procedure #759

Closed
makayabou opened this issue Feb 25, 2023 · 2 comments · Fixed by #760
Assignees
Labels

Comments

@makayabou
Copy link

I followed Basic SQL Alchemy Application with Session in Quickstart session of doc at https://flask-security-too.readthedocs.io/en/stable/quickstart.html#basic-sqlalchemy-application-with-session , and when I started my app I could access login page but after login with test user, I'm redirected to an error page saying:


OperationalError

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user
[SQL: SELECT anon_1.user_id AS anon_1_user_id, anon_1.user_email AS anon_1_user_email, anon_1.user_username AS anon_1_user_username, anon_1.user_password AS anon_1_user_password, anon_1.user_last_login_at AS anon_1_user_last_login_at, anon_1.user_current_login_at AS anon_1_user_current_login_at, anon_1.user_last_login_ip AS anon_1_user_last_login_ip, anon_1.user_current_login_ip AS anon_1_user_current_login_ip, anon_1.user_login_count AS anon_1_user_login_count, anon_1.user_active AS anon_1_user_active, anon_1.user_fs_uniquifier AS anon_1_user_fs_uniquifier, anon_1.user_confirmed_at AS anon_1_user_confirmed_at, role_1.id AS role_1_id, role_1.name AS role_1_name, role_1.description AS role_1_description, role_1.permissions AS role_1_permissions 
FROM (SELECT user.id AS user_id, user.email AS user_email, user.username AS user_username, user.password AS user_password, user.last_login_at AS user_last_login_at, user.current_login_at AS user_current_login_at, user.last_login_ip AS user_last_login_ip, user.current_login_ip AS user_current_login_ip, user.login_count AS user_login_count, user.active AS user_active, user.fs_uniquifier AS user_fs_uniquifier, user.confirmed_at AS user_confirmed_at 
FROM user 
WHERE lower(user.email) = lower(?)
 LIMIT ? OFFSET ?) AS anon_1 LEFT OUTER JOIN (roles_users AS roles_users_1 JOIN role AS role_1 ON role_1.id = roles_users_1.role_id) ON anon_1.user_id = roles_users_1.user_id]
[parameters: ('test@me.com', 1, 0)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

Steps to reproduce:


makayabou@domani:~/dev/flask_secure$ uname -a
Linux domani 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux
makayabou@domani:~/dev/flask_secure$ python3 --version
Python 3.9.2
makayabou@domani:~/dev/flask_secure$ python3 -m venv venv
makayabou@domani:~/dev/flask_secure$ source venv/bin/activate
(venv) makayabou@domani:~/dev/flask_secure$ pip install flask-security-too[common] sqlalchemy
Collecting flask-security-too[common]
(venv) makayabou@domani:~/dev/flask_secure$ pip show flask-security-too |grep Version
Version: 5.1.0
(venv) makayabou@domani:~/dev/flask_secure$ pip show Flask |grep Version
Version: 2.2.3
(venv) makayabou@domani:~/dev/flask_secure$ pip show sqlalchemy |grep Version
Version: 2.0.4
(venv) makayabou@domani:~/dev/flask_secure$ touch app.py models.py database.py

Then I just copy file content from doc as it is, and run flask run

thank you

@jwag956 jwag956 self-assigned this Feb 26, 2023
@jwag956 jwag956 added the bug label Feb 26, 2023
@jwag956
Copy link
Member

jwag956 commented Feb 26, 2023

When I modified the quickstart to not use @before_first_request, which Flask deprecated, it broke flask run.
To run the sample: python app.py should work.

I'll update the docs. thanks.

jwag956 added a commit that referenced this issue Feb 27, 2023
When changing from @app.before_first_request which Flask deprecated, the entire DB initial setup was placed in the __main__ block - thus using flask run to start the examples didn't work.

closes #759
jwag956 added a commit that referenced this issue Feb 27, 2023
When changing from @app.before_first_request which Flask deprecated, the entire DB initial setup was placed in the __main__ block - thus using flask run to start the examples didn't work.

closes #759
@makayabou
Copy link
Author

thank you very much for your very fast answer, it works now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants