I’ve seen two approaches which I’m going to post in the comments to see which one is considered best. Feel free to suggest others.
3 points
Depends on the use case; the question is, do you need to construct and destroy the connection inside each method, or can you do it once, at the start of the program, and exit at the end?
db = Db(DB_FILE)
post_id = insert_post(db,"hello")
comment_id = insert_comment(db,post_id)
db.close()
3 points
Have you thought about using an ORM?
3 points
29 points
*
Deleted by creator
29 points
*
Deleted by creator
8 points