Database class for duckdb and sqlite

Database class for duckdb and sqlite

Public fields

db

a character string specifying a database name.

table

a character string specifying a table name.

con

a database connection object.

tbl

a dplyr::tbl object.

Methods


Method new()

Usage

dbase$new(db = NULL, table = NULL, ...)

Arguments

db

a character string specifying a database name.

table

a character string specifying a table name.

...

ignored

Returns

NULL


Method print()

Usage

dbase$print(...)

Arguments

...

ignored

Returns

NULL create a db if not exits


Method open_db()

Usage

dbase$open_db(db = NULL, table = NULL, ...)

Arguments

db

a character string specifying a database name.

table

a character string specifying a table name.

...

others to be passed to duckdb::duckdb or RSQLite::SQLite, or dbConnect


Method open_table()

Usage

dbase$open_table(table = NULL)

Arguments

table

a character string specifying a table name.

Returns

NULL close db


Method finalize()

Usage

dbase$finalize()

Returns

NULL close db


Method close()

Usage

dbase$close()

Returns

NULL list of table names


Method list_tables()

Usage

dbase$list_tables()

Returns

character vector Read Tables


Method read_tables()

Usage

dbase$read_tables(tables = NULL)

Arguments

tables

a character vector specifying table names.

Returns

list of dataframe Read Table


Method read_table()

Usage

dbase$read_table(table = NULL)

Arguments

table

a character string specifying a table name.

Returns

dataframe


Method read_data()

Usage

dbase$read_data(..., verbose = TRUE)

Arguments

...

dplyr::filter expressions

verbose

a logical specifying whether to print the time or not. Write Table


Method write_table()

Usage

dbase$write_table(value, name = NULL, overwrite = TRUE, append = FALSE, ...)

Arguments

value

data.frame

name

a character string specifying a table name. SQLite table names are not case sensitive, e.g., table names ABC and abc are considered equal.

overwrite

a logical specifying whether to overwrite an existing table or not. Its default is FALSE.

append

a logical specifying whether to append to an existing table in the DBMS. Its default is FALSE.

...

others to be passed to dbWriteTable Write Tables


Method write_tables()

Usage

dbase$write_tables(values, names = NULL, overwrite = TRUE, append = FALSE, ...)

Arguments

values

a list of data.frame

names

a character vector specifying table names.

overwrite

a logical specifying whether to overwrite an existing table or not. Its default is FALSE.

append

a logical specifying whether to append to an existing table in the DBMS. Its default is FALSE.

...

others to be passed to dbWriteTable


Method clone()

The objects of this class are cloneable with this method.

Usage

dbase$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.