You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6.3 KiB

TODO: - create flask app - create symple db with readings - add the form input to db - fetch all rows - getallrows returns a list to be iterated with jinja - and visualize them in the homepage (
) - fetch all tables function - current date when posting in new item - create new tables - show all tables - edit items - remove item/entry from a table - create tag system (type, topics, notes) - sort notes (what if notes had their own tag system that interacts with the one of the resources?) same goes for authors,create a table of authors that then can relate to biografies and connections for the topics they treat or for their personal connections... too much? ----- Notes ----- # I wanted to create a reading list for the summer, in which I could add my comments and organize the readings through some personal categories. As I was also interested in relational tables and databases I started to do some tutorials with sqlite. This is the first attempt to apply those tutorials to the library, it's gonna be very basic initially, but I'll try to document the steps on the way. At the moment I have a vague idea of how the project can be developed but I'm really not aware of all the steps for sure. So this is the process: I write initially a raw todo list with main steps I want to reach (like using flask, creating database etc), then I try to figure out the steps in-between to accomplish a main step. It ain't easy though. I got stuck immediately when I tried to create the Flask application: I needed to register the prefix middleware to be able to see the front-end on the right port and url (asked to kamo and then copy pasted the lines about the prefix middleware from another project on the soupboat) I created the first table of the database by running the create_table() funct in the add() url, which was a pretty ugly procedure, but then I could write a simpler function to add_book() that refers directly to that table (not so abstracted in this case, but will fix this part later on) getAllRow() is also related to specific table of a db, so need to make it more abstract/general In the beginning I wasn't sure that getAllRows() should return something, but as I understood I need to display the rows with jinja and html I got that I need a list of objects (in this case the rows of the db with books) to be able to populate the html table with my data ok, it took me a while to understand how to pass the list of dictionaries (the reading list that i got from the funct getAllRows()) to the frontend. but it was because I didn't want to recreate the object of the row again, is there a quicker way to pass the list with all the arguments of its dictionaries? yes there was a muh quiker way, just return the function getAllRows directly with the name of the db, it will pass directly the reding list to jinja Right now I have something that looks like a very raw table. I'm thinking what's the next step. I'd like to create a system of tags but also a system of notation for each book. I'll do some research on notation and tag systems and a tutorial on relational tables didn't do anything for days hahah I don't remember clearly what i was doing so documentation really helps me getting back on track 15/09/22 It's been a month that I haven't touched this proj. really difficult to pick up on what i did, because there is not a clear method in the documentation either. so now I will try to write the process only here and to reference the (current) lines of things 24/09/22 I've created a repo on git to be able to work on vsc and I used a virtual environment to develop the flask application. I did it by typing the command $ python -m venv folder_name I have a question: can I use flask without venv? Actually yes, even if at first I thought it wasn't possible, just because I blindly trusted people on Stack overflow, or by following the process on flask tutorials I got to set up this virtaulenv. The difference without the virtual env is that all the dependencies that I need would be installed globally on my computer and it might be unconvenient when a version of them will change or if I have a lot of stuff to download. So it turned out that creatinf a virtualenv could be a good practice. VIRTUAL ENVIRONMENT: "The virtual environment is basically a room open for your specific coding project. Instead of using os-wide defined Python or Python packages, it aims to isolate your Python and its dependent packages from all projects that are hosted by your computer." https://medium.com/@pinareceaktan/what-is-this-virtual-environments-in-python-and-why-anyone-ever-needs-them-7e3e682f9d2 "No, there is no requirement to use a virtualenv. No project ever would require you to use one; it is just a method of insulating a collection of Python libraries from other projects. I personally do strongly recommend you use a virtualenv, because it makes it much, much easier to swap out versions of libraries and not affect other Python projects." https://stackoverflow.com/questions/32756711/is-it-necessary-to-use-virtualenv-to-use-flask-framework 27/06/22 I'm not sure how to continue at this point so I decided to check some tutorials and go through the steps they make, to understand some other good practices for databases. https://www.digitalocean.com/community/tutorials/how-to-use-one-to-many-database-relationships-with-flask-and-sqlite https://www.digitalocean.com/community/tutorials/how-to-modify-items-in-a-one-to-many-database-relationships-with-flask-and-sqlite https://www.digitalocean.com/community/tutorials/how-to-use-many-to-many-database-relationships-with-flask-and-sqlite 28/09/22 ok, after a few tutorials I realized there are other ways of building this relational database with reading lists and notes and references, so I'm gonna move this log on a md file, and re do everything from scratch since it doesn't make sense as it is now. or maybe should I publish this log on the console log of the client? It is handier if the code is distributed in more files, with a dedicated schema.sql file and an init_db.py file where i can hadle the construction of the database this way of working reminds me of a tapestry, with threads being pulled from both the front and the back of the weaving frame 03/12/22 Ok. I'm doing everything from scratch again reason: the database design is not ok for what I wanna do D: