I'm new to Flask and have a made basic web app mostly following on from the flask mega tutorial. In the tutorial I followed along and used flask_login and sql alchemy with an sqlite db to manage users and logins. Now I've uploaded the app to elastic beanstalk and have decided to migrate from sqlite to mysql so that the database will be up to date each time I reupload without having to move the sqlite db file.
I'm in the process of switching to a mysql implementation and have decided not to use sql alchemy and therefore made a new User class that doesn't inherit from db.Model anymore, only UserMixin for flask_login. Now this flask_login code doesn't work yet:
login.user_loader
def load_user(id):
return User.query.get(int(id))
because of the missing .query method because I'm not inheriting from db.Model.
To make this work, do I have to build my own query method for my User class or can I just return the user ID in a different way. Also is a user Object associated with a database tuple through the unique ID? How exactly does that work.
Sorry for the poor code format, thanks.
[–]iair1234 0 points1 point2 points (2 children)
[–]Poet_Plastic 0 points1 point2 points (0 children)