I have a method to delete a record from a specific table:

def del_record(self, id): Table1[id].delete_instance() 

Is it possible in this case to make it possible to delete a record from any table by passing for example its name as a parameter?

    2 answers 2

     def add_item(self, id, modelname): modelname[id].delete_instance() 

    In modelname, pass the name of the class of the model, in your case it is Table1 .

    • no, it won't work like this - MyNick

    Then, can I manually create a SQL query to delete the record from the table?

     DELETE FROM <Имя Таблицы> WHERE <Условие отбора записей> 

    Such code will turn out:

     def del_record(self, table_name, id): sql = "DELETE FROM {} WHERE id=?".format(table_name) db.execute_sql(query, (id,)) 

    Ps.