Write to a database from Modal popup

I have a modal popup in my application that accepts data from users. I’d like to save what the user inputs into the fields to a database?

How do I connect my dash app to a database and save information/write to a database?