'How to insert values in sqlite by not giving the values but the name of the tuple containing the values

My Question: how to write the INSERT statement in such a way that all values collected in a Tuple are inserted in my sqlite db?

explanation I have a simple sqlite db named: lifestyle. Onlye one table, same name. This table contains values like date, weight, etc. The db can be updated by the user by giving in the values for that day. The values are (using a python build form) collected in a python Tuple, called day_update.

Code examples(first with all values in statement, 2nd with name of Tuple):

This (example) code works fine when the values are hard coded:

create_lifestyle = """
INSERT INTO
  lifestyle (date, weight, belly, start_eat, end_eat, cal_in, cal_extraout)
VALUES
  ('30-01-2022', 93.7, 0, 11.00, 19.00, 1591, -413)
"""
execute_query(connection, create_lifestyle)

But this is what I want/need, this to work, but I can't figure out how (day_update is a Tuple that prints out exactly the same as in the above example):

    create_lifestyle = """
    INSERT INTO
          lifestyle (date, weight, belly, start_eat, end_eat, cal_in, cal_extraout)
    VALUES 
      day_update;
    """
    execute_query(connection, create_lifestyle)

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source