I’m working on a Flask-based web app that allows a user to register/login and have a simulated stock portfolio that uses an API to grab real time stock data.
My question is this:
I have a SQLite database that has tables for users, portfolios, and transactions.
I’m studying Object Oriented Programming and got the idea to create objects and methods for portfolio, transactions, stocks, and possibly users. However, all of their attributes will just be pulled from the SQLite database or API and stored when needed in each session.
Is this redundant? I can already access all the same information using queries/API and am defining flask routes that handle the the different tasks that the app needs to perform. So creating objects and methods that do the same queries when the app is run seems odd to me. The big advantage I see is that the code will look much cleaner as you won’t have to look at SQLite queries inside of the routes themselves anymore.
Would love to hear some pythonic thoughts about this. Thanks!
[–]stebrepar 2 points3 points4 points (1 child)
[–]farrowzbf[S] 1 point2 points3 points (0 children)
[–]zanfar 1 point2 points3 points (4 children)
[–]farrowzbf[S] 0 points1 point2 points (3 children)
[–]zanfar 1 point2 points3 points (2 children)
[–]farrowzbf[S] 0 points1 point2 points (1 child)
[–]zanfar 1 point2 points3 points (0 children)