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

query problem #12

Open
nim4n opened this issue Jan 24, 2017 · 2 comments
Open

query problem #12

nim4n opened this issue Jan 24, 2017 · 2 comments

Comments

@nim4n
Copy link

nim4n commented Jan 24, 2017

Hi
I use UserMixin to create my User class:

class User(UserMixin):
    email = db.Column(db.String(255), unique=True, nullable=False)
    password = db.Column(db.String(255), nullable=False)
    registered_on = db.Column(db.DateTime, nullable=False)
    admin = db.Column(db.Boolean, nullable=False, default=False)

I can save data to the database but I can't fetch anything from database! I think the problem is on type part, when I check the query statement I can see this:

print(User.query)
SELECT fp_user.id AS fp_user_id, fp_user.type AS fp_user_type, fp_user.email AS fp_user_email, fp_user.password AS fp_user_password, fp_user.registered_on AS fp_user_registered_on, fp_user.admin AS fp_user_admin 
FROM fp_user 
WHERE fp_user.type IN (NULL)

and because of this where part nothing coming out from this query!

@seafoodfriedrice
Copy link

Having the same problem also. No problem adding a user, which shows up in the database:

# select * from fp_user;
 id | type | username |                                           password                                            
----+------+----------+-----------------------------------------------------------------------------------------------
  1 |      | flask    | pbkdf2:sha256:50000$32tQqbEE$57c91570bb2b508d8ce4233facbe4154dba14feefbd20b1671b56fe17aea5ddf
(1 row)

But when I query the User class in Python I get an empty list:

>>> User.query.all()
[]

@Saravanakumar46
Copy link

Saravanakumar46 commented Dec 7, 2017

_ tablename _ = 'fp_user'
_ table_args _ = {'extend_existing': True}

Add these lines in User model. That's worked for me.

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

No branches or pull requests

3 participants