Skip to contents

Run a query against a GlareDB database

Usage

glaredb_sql(query, connection = NULL)

glaredb_prql(query, connection = NULL)

glaredb_execute(query, connection = NULL)

Arguments

query

A character of the query to run.

  • For glaredb_sql() and glaredb_execute(), an SQL query.

  • For glaredb_prql(), a PRQL query.

connection

A GlareDB connection object or NULL. If NULL, the default in-memory database is used.

Value

GlareDB execusion output. For glaredb_execute(), the value is returned invisibly.

Examples

glaredb_sql("SELECT 'hello from R' as hello") |>
  as_glaredb_table()
#> ┌──────────────┐
#> │ hello        │
#> │ ──           │
#> │ Utf8         │
#> ╞══════════════╡
#> │ hello from R │
#> └──────────────┘

glaredb_prql("from [
  {a=5, b=false},
  {a=6, b=true},
]") |>
  as_glaredb_table()
#> ┌───────┬─────────┐
#> │     a │ b       │
#> │    ── │ ──      │
#> │ Int64 │ Boolean │
#> ╞═══════╪═════════╡
#> │     5 │ false   │
#> │     6 │ true    │
#> └───────┴─────────┘

glaredb_execute("CREATE TABLE my_table (a int)")
glaredb_execute("INSERT INTO my_table VALUES (1), (2)")
glaredb_sql("SELECT * FROM my_table") |>
  as_glaredb_table()
#> ┌───────┐
#> │     a │
#> │    ── │
#> │ Int32 │
#> ╞═══════╡
#> │     1 │
#> │     2 │
#> └───────┘