def migrate(db, trackers): c = db.cursor() tracker = trackers["cigarette"] habit_dict = { "archived": 0, "color": 11, "name": tracker["label"], "description": "smoking", "freq_den": 1, "freq_num": 1, "highlight": 0, "position": 4, "question": "Did you smoke today punk?", "uuid": tracker["id"], } add_to_database(c, habit_dict) # DEBUGGING c.execute("""select * from Habits""") print(c.fetchall()) def add_to_database(cursor, habit_dict): placeholder = ", ".join("?" * len(habit_dict)) columns = ", ".join(habit_dict.keys()) values = list(habit_dict.values()) sql = "insert into `{table}` ({columns}) values ({values});".format( table="Habits", columns=columns, values=placeholder ) cursor.execute(sql, values) # grab next tracker info # look for unique id of next habit # if exists skip and warn user # insert tracker into habit table # FOR REPETITION MIGRATION # c.execute( # """ # INSERT INTO # Repetitions(id, habit, timestamp, value) # VALUES (NULL, 5, 1629676800000, 2) # """ # ) # c.execute( # """ # INSERT INTO # Repetitions(id, habit, timestamp, value) # VALUES (NULL, 6, 1629676800000, 2) # """ # ) # """ # ) # """ # ) # """ # ) # """ # ) # """ # ) # """ # ) # """ # ) # """ # ) # """ # ) # """ # )