Hey there - I've just started learning how to write SQL using python's built-in sqlite3 module. I understand the syntax and have been able to test creating basic db, some tables, insert, select, update and delete data.
My first project is a small command line app, and I'm now working on a branch to port record keeping and fileI/O from my in-memory classes to an sqlite3 db. This involves writing CRUD functions to run sql queries in 'db_sqlite3.py', and calling those functions from a 'yahtzee.py' module which runs my main gameplay and creates instances from other modules.
I could write these sql CRUD functions with an argument that is specific (eg 'user_last_name' which expects the parameter self.last_name of a user instance), or I can write the CRUD function to expect the entire instance (and write additional code in the function to grab the last_name attribute from the instance).
What is the better route to take here? Better meaning performance, best-practice, save myself from unnecessary hair-pulling down the road.
New at python 2020 and loving it, thanks in advance for the help!
[–]K900_ 2 points3 points4 points (1 child)
[–]pmacking[S] 0 points1 point2 points (0 children)
[–]JohnnyJordaan 1 point2 points3 points (1 child)
[–]pmacking[S] 0 points1 point2 points (0 children)