sql_editor: SQL editor widget

View source: R/sql.R

sql_editorR Documentation

SQL editor widget

Description

A thin text_area() subclass with SQL highlighting. When connection is supplied, execute_key runs the selected SQL, or the full buffer if nothing is selected. Queries run synchronously in the current R process.

Usage

sql_editor(
  value = "",
  id = NULL,
  connection = NULL,
  execute_key = "ctrl+enter",
  execution = c("query", "execute"),
  line_numbers = TRUE,
  tab_size = 2L,
  ...,
  result_mode = c("data", "lazy"),
  query_adapter = NULL
)

Arguments

value

Initial SQL text.

id

Optional widget id.

connection

A db_connection() wrapper or raw DBI connection.

execute_key

Key binding used to execute SQL.

execution

Either "query" (DBI::dbGetQuery) or "execute" (DBI::dbExecute).

line_numbers

Show line numbers? Defaults to TRUE.

tab_size

Spaces inserted by Tab.

...

Additional arguments passed to TextArea.

result_mode

Query result mode: "data" materializes the result (the default); "lazy" returns a db_query_source() for a paged table. Lazy mode is available only with execution = "query".

query_adapter

Optional backend pager callbacks passed to db_query_source().

Value

A TextArea subclass with an execute() method.


termr documentation built on Oct. 21, 2026, 5:13 p.m.