0

When I query my sqlalchemy database it does not display all the columns but only one for example

User.query.all()

returns

User('Andrew')

but it should return

User('Andrew','Andrew677@gmail.com')

Below is my model

class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(10), unique=True, nullable=False)
    email = db.Column(db.String(15), unique=True, nullable=False)
    password = db.Column(db.String(30), nullable=False)

I believe I have configured sqlalchemy correctly because it does store users when I create them but does not allow me to query also when I use

User.query.count() 

it returns the correct amount of users in the table but it does not return all the columns, this is happening in all my tables

ARDev
  • 11
  • 1
  • 3
  • A loop like this should work: `users = User.query.all() for user in users: print(user.username)` – Kate Apr 04 '21 at 23:11
  • You should read https://stackoverflow.com/questions/7784148/understanding-repr-function-in-python. What you see is just the representation of a `User`. You should explicitly access the attributes to produce any desired output format. – Ilja Everilä Apr 05 '21 at 08:04

0 Answers0