| Title: | R Interface to the 'LadybugDB' Embedded Graph Database |
|---|---|
| Description: | Provides an R interface to 'LadybugDB', an embedded columnar graph database using the 'Cypher' query language. 'LadybugDB' was formerly known as 'Kuzu'. This package uses native 'Rcpp' bindings to the 'LadybugDB' C library, requiring no 'Python' runtime. |
| Authors: | Raden Muhammad Hadi [aut, cre] |
| Maintainer: | Raden Muhammad Hadi <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.4 |
| Built: | 2026-10-17 09:35:46 UTC |
| Source: | https://github.com/hadimaster65555/rladybugdb |
Convert a LadybugDB result to an Arrow Table
as_arrow_table(x, ...)as_arrow_table(x, ...)
x |
An |
... |
Unused. |
An arrow::Table backed by LadybugDB's Arrow C Data export.
Extracts node and relationship columns from a LadybugDB query result and
constructs an igraph::graph_from_data_frame() object.
as_igraph(x, ...)as_igraph(x, ...)
x |
An |
... |
Unused; kept for S3 compatibility. |
Node columns must have LadybugDB type NODE and relationship columns type
REL/RELATIONSHIP. When the result contains no structural columns the
function aborts with an informative error.
An igraph::igraph object.
## Not run: db <- lb_database(":memory:") conn <- lb_connection(db) lb_execute(conn, "CREATE NODE TABLE Person (name STRING, PRIMARY KEY(name))") lb_execute(conn, "CREATE REL TABLE Knows (FROM Person TO Person)") lb_execute(conn, "CREATE (:Person {name:'A'})-[:Knows]->(:Person {name:'B'})") result <- lb_execute(conn, "MATCH (a:Person)-[r:Knows]->(b:Person) RETURN a, r, b") g <- as_igraph(result) ## End(Not run)## Not run: db <- lb_database(":memory:") conn <- lb_connection(db) lb_execute(conn, "CREATE NODE TABLE Person (name STRING, PRIMARY KEY(name))") lb_execute(conn, "CREATE REL TABLE Knows (FROM Person TO Person)") lb_execute(conn, "CREATE (:Person {name:'A'})-[:Knows]->(:Person {name:'B'})") result <- lb_execute(conn, "MATCH (a:Person)-[r:Knows]->(b:Person) RETURN a, r, b") g <- as_igraph(result) ## End(Not run)
Convert an lb_result to a tbl_graph (tidygraph)
as_tbl_graph(x, ...)as_tbl_graph(x, ...)
x |
An |
... |
Unused. |
A tidygraph::tbl_graph() object.
Convert a LadybugDB result to a tibble
as_tibble(x, ...)as_tibble(x, ...)
x |
An |
... |
Passed to |
A tibble.
Materialization preserves the current streaming cursor, so it is repeatable
and does not change subsequent calls to lb_fetch().
## S3 method for class 'lb_result' as.data.frame(x, ...)## S3 method for class 'lb_result' as.data.frame(x, ...)
x |
An |
... |
Unused. |
A data frame.
Format a LadybugDB interval
## S3 method for class 'lb_interval' format(x, ...)## S3 method for class 'lb_interval' format(x, ...)
x |
An |
... |
Unused. |
Create a LadybugDB DBI driver
Ladybug()Ladybug()
A LadybugDriver.
LadybugDB DBI connection
databaseNative database object.
connectionNative connection object.
stateMutable connection state.
bigintINT64 conversion policy.
This function is deprecated. The C library is now bundled with the package and no Python installation is required.
ladybugdb_install(...)ladybugdb_install(...)
... |
Ignored. |
Invisible NULL.
## Not run: ladybugdb_install() # no longer needed ## End(Not run)## Not run: ladybugdb_install() # no longer needed ## End(Not run)
Returns TRUE if the native LadybugDB C library is loaded and functional.
ladybugdb_is_installed()ladybugdb_is_installed()
TRUE or FALSE.
ladybugdb_is_installed()ladybugdb_is_installed()
Return the LadybugDB C library version string
ladybugdb_version()ladybugdb_version()
A character string, e.g. "0.20.4".
ladybugdb_version()ladybugdb_version()
LadybugDB implements the standard DBI lifecycle, query, binding, fetch,
transaction, quoting, and table-metadata generics. LadybugDB's native schema
distinguishes node and relationship tables, so relational helpers outside
this documented subset are intentionally left to graph-specific Cypher and
the lb_* API. SQL SELECT, dbWriteTable(), and dbAppendTable() are not
translated. dbExecute() returns zero after successful DDL/DML because the
LadybugDB 0.20.4 C result summary does not expose a stable affected-row
count. Applicable driver behavior is exercised with a focused DBItest
subset.
LadybugDB DBI result
connectionOwning DBI connection.
stateMutable result state.
statementOriginal Cypher statement.
Transaction control
lb_begin(conn) lb_commit(conn) lb_rollback(conn)lb_begin(conn) lb_commit(conn) lb_rollback(conn)
conn |
An |
Invisible conn.
Closing an object more than once is harmless. A connection cannot be closed while it owns open results, and a database cannot be closed while it owns open connections.
lb_close(x, ...)lb_close(x, ...)
x |
An |
... |
Unused. |
Invisible NULL.
Open a connection to a LadybugDB database
lb_connection(database, num_threads = NULL)lb_connection(database, num_threads = NULL)
database |
An |
num_threads |
Positive integer execution thread limit, or |
An lb_connection object.
Registers a temporary Arrow-backed table through the Arrow C Data Interface, copies its rows into an existing native node table, and unregisters it. No data-frame or CSV conversion is performed.
lb_copy_from_arrow(conn, value, table)lb_copy_from_arrow(conn, value, table)
conn |
An |
value |
An Arrow Table, RecordBatch, or object accepted by
|
table |
Existing target node table name. |
The COPY query's lb_result.
Load a CSV file into a LadybugDB table
lb_copy_from_csv(conn, path, table, header = TRUE, delim = ",", ...)lb_copy_from_csv(conn, path, table, header = TRUE, delim = ",", ...)
conn |
An |
path |
Path to a CSV file. |
table |
Existing target table name. |
header |
Does the file contain a header? |
delim |
One-character delimiter. |
... |
Named COPY options. Values must be scalar logical, numeric, or character values; option names are validated identifiers. |
An lb_result.
Uses native Arrow transport when the optional arrow package is available.
Otherwise it uses the explicit CSV loader as a compatibility fallback.
lb_copy_from_df(conn, df, table)lb_copy_from_df(conn, df, table)
conn |
An |
df |
A data frame. |
table |
Existing target table name. |
An lb_result.
Creates or opens a LadybugDB database. LadybugDB v0.20.4 can read the storage formats created by v0.15.x. For incompatible future formats, export with the original engine and import into a fresh database.
lb_database(path = ":memory:", read_only = FALSE, config = list())lb_database(path = ":memory:", read_only = FALSE, config = list())
path |
File-system path, or |
read_only |
Open in read-only mode? |
config |
Named list of LadybugDB system configuration overrides. Valid
names are |
An lb_database object.
Sends a Cypher query string to LadybugDB and returns an lb_result object.
For DDL or DML statements (CREATE TABLE, CREATE, MERGE, …) the result
contains metadata; for MATCH/RETURN it contains rows.
lb_execute(conn, query, parameters = NULL)lb_execute(conn, query, parameters = NULL)
conn |
An |
query |
A single character string containing a Cypher query. |
parameters |
A named list of query parameters for parameterised queries.
|
An object of class lb_result.
## Not run: db <- lb_database(":memory:") conn <- lb_connection(db) lb_execute(conn, "CREATE NODE TABLE Person (name STRING, PRIMARY KEY(name))") lb_execute(conn, "CREATE (:Person {name: $name})", parameters = list(name = "Alice")) ## End(Not run)## Not run: db <- lb_database(":memory:") conn <- lb_connection(db) lb_execute(conn, "CREATE NODE TABLE Person (name STRING, PRIMARY KEY(name))") lb_execute(conn, "CREATE (:Person {name: $name})", parameters = list(name = "Alice")) ## End(Not run)
Fetch rows from a LadybugDB result
lb_fetch(result, n = 10000) lb_has_next(result) lb_reset(result)lb_fetch(result, n = 10000) lb_has_next(result) lb_reset(result)
result |
An |
n |
Maximum rows to fetch. |
A data frame. Repeated calls advance the result cursor.
Fetch a chunk as an Arrow Table
lb_fetch_arrow(result, n = Inf)lb_fetch_arrow(result, n = Inf)
result |
An |
n |
Maximum rows to fetch. |
An arrow::Table.
These are thin wrappers around LadybugDB's extension Cypher commands.
Remote installation and updating are unavailable in the CRAN build because
those operations require a native networking stack. Compatible extensions
installed outside R can still be loaded with lb_load_extension().
lb_list_extensions(conn) lb_install_extension(conn, name) lb_load_extension(conn, name) lb_update_extension(conn, name)lb_list_extensions(conn) lb_install_extension(conn, name) lb_load_extension(conn, name) lb_update_extension(conn, name)
conn |
An |
name |
Official extension name. |
lb_list_extensions() returns a data frame; the mutation helpers
return an lb_result.
Retrieve the next result from a multi-statement query
lb_next_result(result)lb_next_result(result)
result |
An |
The next lb_result, or NULL.
Convenience wrapper around lb_execute() that immediately converts the
result to an R data.frame. Equivalent to
as.data.frame(lb_execute(conn, query, ...)).
lb_query(conn, query, parameters = NULL, ...)lb_query(conn, query, parameters = NULL, ...)
conn |
An |
query |
A single character string containing a Cypher query. |
parameters |
A named list of query parameters for parameterised queries.
|
... |
Passed to |
A data.frame.
## Not run: db <- lb_database(":memory:") conn <- lb_connection(db) lb_execute(conn, "CREATE NODE TABLE Person (name STRING, age INT64, PRIMARY KEY(name))") lb_execute(conn, "CREATE (:Person {name: 'Alice', age: 30})") df <- lb_query(conn, "MATCH (p:Person) RETURN p.name, p.age") ## End(Not run)## Not run: db <- lb_database(":memory:") conn <- lb_connection(db) lb_execute(conn, "CREATE NODE TABLE Person (name STRING, age INT64, PRIMARY KEY(name))") lb_execute(conn, "CREATE (:Person {name: 'Alice', age: 30})") df <- lb_query(conn, "MATCH (p:Person) RETURN p.name, p.age") ## End(Not run)
Return query timing information
lb_query_summary(result)lb_query_summary(result)
result |
An |
A list with compilation and execution times in milliseconds.
Inspect result metadata
lb_result_info(result)lb_result_info(result)
result |
An |
A named list.
Configure and interrupt queries
lb_set_timeout(conn, milliseconds) lb_interrupt(conn)lb_set_timeout(conn, milliseconds) lb_interrupt(conn)
conn |
An |
milliseconds |
Non-negative timeout in milliseconds. Zero disables the timeout. |
Invisible conn.
Run code with an automatically closed LadybugDB connection
with_lb_connection(path = ":memory:", code, ..., num_threads = NULL)with_lb_connection(path = ":memory:", code, ..., num_threads = NULL)
path |
Database path. |
code |
Code evaluated with |
... |
Passed to |
num_threads |
Passed to |
The value of code.