the function below is executed before a dataframe, after executing it it does not edit the database, can you help me
def edit_entry(self, id, epi_name=None, quantity=None, value=None, transaction_type=None, date=None, requester=None, CA=None):
logging.debug(f"Called edit_entry with ID={id}")
updates = {
"epi_name": epi_name,
"quantity": quantity,
"value": value,
"transaction_type": transaction_type,
"date": date,
"requester": requester,
"CA": CA
}
# Remove os valores que são None
updates = {key: val for key, val in updates.items() if val is not None}
if not updates:
logging.warning("No values provided for update. Exiting function.")
return
placeholders = ', '.join([f"{key} = ?" for key in updates.keys()])
sql = f"UPDATE epi_stock SET {placeholders} WHERE id = ?"
logging.debug(f"Executing SQL: {sql} with values {updates.values()}")
try:
with sqlite3.connect(DB_NAME) as connection:
cursor = connection.cursor()
logging.debug(f"Connected to database: {DB_NAME}")
values = list(updates.values()) + [id]
cursor.execute(sql, values)
connection.commit()
logging.debug(f"Changes committed to database.")
except sqlite3.Error as e:
st.write(f"Erro ao editar registro: {e}")
logging.error(f"Error while editing entry: {e}")