Package {frostlake}


Title: 'DBI' Backend for the 'Frostlake' Database Engine
Version: 0.1.0
Description: A 'DBI'-compliant driver for 'Frostlake', a SQL engine emulating core 'Snowflake' features. Speaks the engine's HTTP protocol against a running 'DatabaseHttpServer': one POST per statement with a session id the server issues on first contact, so session state (current database/schema, transactions) persists across statements. Query results arrive as data frames with Snowflake types mapped to R types.
License: Apache License (== 2.0)
URL: https://github.com/Frostlake-DB/frostlake-r
BugReports: https://github.com/Frostlake-DB/frostlake-r/issues
Encoding: UTF-8
Depends: R (≥ 4.1)
Imports: DBI (≥ 1.1.0), curl, jsonlite, methods
Suggests: testthat (≥ 3.0.0), withr
Config/testthat/edition: 3
Collate: 'utils.R' 'substitute.R' 'wire.R' 'driver.R' 'connection.R' 'result.R' 'tables.R'
NeedsCompilation: no
Packaged: 2026-10-01 20:14:35 UTC; nous
Author: MLorek [aut, cre, cph]
Maintainer: MLorek <michal.lorek@gmail.com>
Repository: CRAN
Date/Publication: 2026-10-14 10:50:02 UTC

DBI driver for the Frostlake database engine

Description

frostlake() returns the DBI driver object. Hand it to dbConnect together with the coordinates of a running Frostlake DatabaseHttpServer; every DBI verb then works on the connection. One HTTP POST per statement carries the SQL and a session id the server issues on first contact, so session state (current database/schema, transactions) persists across statements.

Usage

frostlake()

Value

A FrostlakeDriver object for dbConnect.

Examples

drv <- frostlake()
drv

# The engine types dbWriteTable() creates columns with, for each R type
DBI::dbDataType(drv, data.frame(id = 1:2, name = c("a", "b"), day = Sys.Date()))

## Not run: 
# Everything below needs a running Frostlake DatabaseHttpServer
library(DBI)
con <- dbConnect(frostlake::frostlake(),
                 host = "localhost", port = 18082,
                 dbname = "MY_DB", schema = "PUBLIC")
# or: dbConnect(frostlake::frostlake(), url = "frostlake://localhost:18082/MY_DB?schema=PUBLIC")

dbExecute(con, "CREATE TABLE people (id INTEGER, name VARCHAR)")
dbExecute(con, "INSERT INTO people VALUES (?, ?)", params = list(1L, "Ada"))
dbGetQuery(con, "SELECT id, name FROM people WHERE id = ?", params = list(1L))

dbWriteTable(con, "SCORES", data.frame(id = 1:3, score = c(9.5, 8, 7)))
dbReadTable(con, "SCORES")
dbDisconnect(con)

## End(Not run)

DBI methods for Frostlake

Description

Implementations of the standard DBI generics for FrostlakeDriver, FrostlakeConnection and FrostlakeResult. Each follows its generic's contract — see the corresponding DBI help page — with these engine-specific notes:

Value

Each method returns what its DBI generic specifies:

See Also

frostlake for connecting.

Examples

# Type mapping needs no server
DBI::dbDataType(frostlake(), data.frame(flag = TRUE, n = 1L, x = 2.5, s = "x"))

## Not run: 
# Everything below needs a running Frostlake DatabaseHttpServer
con <- DBI::dbConnect(frostlake(), url = "frostlake://localhost:18082/MY_DB")
res <- DBI::dbSendQuery(con, "SELECT 1 AS one")
DBI::dbColumnInfo(res)
DBI::dbFetch(res)
DBI::dbClearResult(res)
DBI::dbDisconnect(con)

## End(Not run)