Where is it best to place the database table code?
-
Please tell me, I have a program that consists of a main, class persona and a class database. There's gonna be an addition, change and disposal in the database, and where it's best to place this base in the first launch of the programme, that it creates a base and that code has not been implemented, how it can be implemented or that's what I can understand. I'll use sqlite3
Where to place this code:conn = sql.connect('data_per.db') cur = conn.cursor() cur.execute("""CREATE TABLE IF NOT EXISTS users( id INTEGER, name TEXT, gender TEXT, weight REAL, height INT, age INT, coefficient REAL ); """) conn.commit()
-
Then do the method in the database so that the entire OBD code is in the same place. When the programme is launched, check the presence of the OBD if it is not available, the method of establishment is called.