DuckDb

class DuckDb @JvmOverloads constructor(dbName: String, dbDirectory: Path = KSL.dbDir, deleteIfExists: Boolean = true) : Database(source)

Facilitates the creation of a database backed by DuckDb. The database will be empty.

Return

a DuckDb configured database

Parameters

dbName

the name of the database

dbDirectory

the directory containing the database. By default, KSL.dbDir.

deleteIfExists

If true, an existing database in the supplied directory with the same name will be deleted and an empty database will be constructed.

Constructors

Link copied to clipboard
constructor(tableDefinitions: Set<DbTableData>, dbName: String, dbDirectory: Path = KSL.dbDir, deleteIfExists: Boolean = true)

This constructs a simple DuckDb database on disk. The database will contain empty tables based on the table definitions. If the database already exists on disk, it will be deleted and recreated.

constructor(dbName: String, dbDirectory: Path = KSL.dbDir, deleteIfExists: Boolean = true)

Types

Link copied to clipboard

Functions

Link copied to clipboard
fun <T : DbTableData> appendDbDataToTable(data: List<T>, tableName: String, schemaName: String? = defaultSchemaName)

Uses DuckDb's Appender to more efficiently append records to the table. The data in the list must be associated with the named table. The table must be within the named schema. The data must not have an auto-increment field.

Link copied to clipboard
fun exportAsLoadableCSV(exportDir: Path = KSL.dbDir)

Exports the database to a directory with loadable default CSV format. See DuckDb documentation.

Link copied to clipboard
fun exportAsLoadableParquetFiles(exportDir: Path = KSL.dbDir)

Exports the database to a directory with loadable default Parquet file format. See DuckDb documentation.

Exports the database to a directory with loadable default Parquet format. See DuckDb documentation.

Link copied to clipboard
fun summarize(tableName: String, schemaName: String? = defaultSchemaName): ResultSet?

Applies DuckDb's summarize query to the table/view