Threading Issue: If you're using a GUI framework (like Tkinter, PyQt, etc.), it might be that your button click is triggering the database action on the main thread, causing the GUI to freeze or crash. To solve this, you should use threading to run your database query on a separate thread. This prevents the main thread (responsible for the GUI) from getting blocked.