Unable to access the input field data (and insert into database)

Depending on where you need to use the data and where the requests come from, you need to set their scope.

If you query is in the app scope, you probably have a page called app and a page called database?

Could you share a screenshot of your page overview and component overview?

You could put the query from app to database. Or you can put it in global. If you reference an input field in a query resource, they have to be in the same scope.