| sql_query | R Documentation |
sql_query() runs an arbitrary SQL query using DBI::dbGetQuery()
and returns a data.frame with the query results.
sql_exec() runs an arbitrary SQL statement using DBI::dbExecute()
and returns the number of affected rows.
These functions are intended as an easy way to interactively run DuckDB without having to manage connections. By default, data frame objects are available as views.
Scripts and packages should manage their own connections and prefer the DBI methods for more control.
sql_query(sql, conn = default_conn())
sql_exec(sql, conn = default_conn())
sql |
A SQL string |
conn |
An optional connection, defaults to |
A data frame with the query result
# Queries
sql_query("SELECT 42")
# Statements with side effects
sql_exec("CREATE TABLE test (a INTEGER, b VARCHAR)")
sql_exec("INSERT INTO test VALUES (1, 'one'), (2, 'two')")
sql_query("FROM test")
# Data frames available as views
sql_query("FROM mtcars")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.