Accessing data from database and displaying in the Ui

Can anyone guide me to how to go on with reading and writing data to db and displaying it on the UI

As in fetching information and populating into fields or as in print formats?

fetching and populating into fields