Interacting with database in panel plugin

I want to simplify the interaction for the average user, so that for example someone can just use a single word in a text field to query a predefined database table.

Is there a way to send queries to the database from the panel plugin by using the selected datasource plugin?
Like for example does anyone know how to interact with the raw sql query editor or know how to access the method that is used to send the query from the sql query editor?