DuckDBConnection

com.softinio.duck4s.DuckDBConnection
See theDuckDBConnection companion class

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

Creates a new DuckDB connection with the specified configuration.

Creates a new DuckDB connection with the specified configuration.

This method establishes a connection to DuckDB using the provided configuration. The connection can be either in-memory or persistent to a file.

Value parameters

config

The database configuration including connection mode, read-only flag, temporary directory, and additional properties. Defaults to in-memory mode.

Attributes

Returns

Either a algebra.DuckDBError.ConnectionError if connection fails, or a DuckDBConnection

See also

algebra.DuckDBConfig for configuration options

Since

0.1.0

Example
\n * // Create an in-memory connection val memConn =
 DuckDBConnection.connect()
// Create a persistent connection val persistentConn =
DuckDBConnection.connect( DuckDBConfig.persistent("/path/to/database.db")
) 

\n *

Executes a block of operations with a DuckDB connection that is automatically closed.

Executes a block of operations with a DuckDB connection that is automatically closed.

This method creates a new connection, executes the provided block, and ensures the connection is properly closed regardless of the outcome. This is the recommended way to work with DuckDB connections.

Type parameters

T

The type of the successful result

Value parameters

block

A function that receives the connection and returns an Either with the result

config

The database configuration. Defaults to in-memory mode.

Attributes

Returns

Either a algebra.DuckDBError.ConnectionError if connection or execution fails, or the result of the block

See also

connect for connection creation without automatic resource management

Since

0.1.0

Example
\n * val result = DuckDBConnection.withConnection() { conn => for _
 <- conn.executeUpdate("CREATE TABLE test (id INTEGER)") count <-
 conn.executeUpdate("INSERT INTO test VALUES (1)") yield count } 

\n *