I am trying to be able to edit and create new data in a sqlite file using python.
def save_updated_data(self, entry_values, update_window, current_row_data): updated_row_data = {} for entry, (label, value) in zip(entry_values, current_row_data.items()): updated_row_data[label] = entry.get() if entry.get() else value row_index = self.data.index(current_row_data) self.data[row_index] = updated_row_data self.save_to_sqlite() messagebox.showinfo("Update", "Data updated successfully!") update_window.destroy() self.display_data()def create_data_window(self, conn): cur = conn.cursor() cur.execute(f"INSERT INTO {table_name} VALUES ({','.join(['?']*len(new_data))})", new_data) conn.commit() messagebox.showinfo("Create Data", "Data successfully created.")def save_created_data(self, entry_values, create_window): cur = conn.cursor() cur.execute(f"INSERT INTO {table_name} VALUES ({','.join(['?']*len(new_data))})", new_data) conn.commit() messagebox.showinfo("Create Data", "Data successfully created.")def save_to_sqlite(self, conn, table_name, row_index, column_index, new_value): cursor = self.conn.execute('SELECT * FROM sqlite_master WHERE type="table" LIMIT 1') table_name = cursor.fetchone()[1] with self.conn: self.conn.execute(f"INSERT INTO {table_name} VALUES (NULL, ?, ?)", (row["column1"], row["column2"])) for row in self.data: self.conn.execute("INSERT INTO road_data VALUES (NULL, ?, ?)", (row["column1"], row["column2"]))
I don't really know why it is not getting saved. It does give me some errors like argument errors. I am only new to coding and I really do enjoy it so far it is just sometimes like these it is difficult. Thank you.