Submit query to Datagrip from plugin

I'm trying to create a plugin to help me explore data. I have a number of queries that I run one after the other when debugging and extracting information. It unfortunately gets messy to keep queries organized especially when individual queries are small and I can write them
I'm trying to plug into the data grid and add some shortcuts to help me jump from data to data.
In the screenshot, I have a certain data id. I am able to extract the selected value and print it as follows
class FindUsersAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val grid = e.getData(DatabaseDataKeys.DATA_GRID_KEY) ?: return
val selection = grid.selectionModel
if (selection.selectedRowCount != 1) return
val row = selection.selectedRows.first()
val col = selection.selectedColumns.first()
val accountId = grid.getDataModel(DataAccessType.DATA_WITH_MUTATIONS)
.getValueAt(row, col)
println("Action: AccountId -> $accountId finding Users")
}
}Now, based on the account Id, I would like to submit a query for datagrid. I would like it to be executed on the same data session and added as a result tab.
I'm lost on how to achieve this in a plugin? Is there a way to programmatically submit a query to the database plugin?
请先登录再写评论。
I was able to do this and run the query, I'm not sure if this is the best way, but it worked.
[2025-12-27 15:59:00] paga> SELECT FinancialTransactionItemId, FinancialAccountId, CreditAmount, DebitAmount, Description, *
FROM [FinancialTransactionItem]
WHERE FinancialTransactionId = 6519
ORDER BY TransactionLineNumber
[2025-12-27 15:59:00] 0 rows retrieved in 392 ms (execution: 31 ms, fetching: 361 ms)
[2025-12-27 15:59:00] paga> SELECT FinancialTransactionItemId, FinancialAccountId, CreditAmount, DebitAmount, Description, *
FROM
[2025-12-27 15:59:00] [S0001][102] Line 2: Incorrect syntax near 'FROM'.
The above code some how results in two queries being executed. It seems to be related to `[`.