com.softinio.duck4s.effect

Members list

Type members

Classlikes

class DuckDBException(val error: DuckDBError, message: String, cause: Option[Throwable] = ...) extends RuntimeException

A Throwable wrapper for com.softinio.duck4s.algebra.DuckDBError, enabling error values to be raised into cats-effect IO.

A Throwable wrapper for com.softinio.duck4s.algebra.DuckDBError, enabling error values to be raised into cats-effect IO.

Value parameters

cause

Optional underlying throwable that caused this error

error

The underlying DuckDBError

message

Human-readable error message

Attributes

Companion
object
Supertypes
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all

Factory methods for creating DuckDBException from com.softinio.duck4s.algebra.DuckDBError values.

Factory methods for creating DuckDBException from com.softinio.duck4s.algebra.DuckDBError values.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
object DuckDBIO

Cats-effect integration for duck4s, providing cats.effect.Resource-based connection management and fs2.Stream-based result set streaming.

Cats-effect integration for duck4s, providing cats.effect.Resource-based connection management and fs2.Stream-based result set streaming.

All JDBC calls are wrapped in cats.effect.IO.blocking to avoid blocking the cats-effect thread pool. Errors are raised as DuckDBException rather than returned as Either values.

Attributes

Note

DuckDB connections are NOT thread-safe. Do not share a single connection across fibers. Use duplicate() or open separate connections per fiber.

Example
 import com.softinio.duck4s.effect.*
val program: IO[Unit] = DuckDBIO.connect().use { conn => for _ <-
conn.executeUpdateIO("CREATE TABLE t (id INTEGER)") _ <-
conn.executeUpdateIO("INSERT INTO t VALUES (1)") rows <-
DuckDBIO.stream(conn, "SELECT id FROM t")(_.getInt("id")).compile.toList _
<- IO(println(rows)) yield () } 
Supertypes
class Object
trait Matchable
class Any
Self type
DuckDBIO.type

Extensions

Extensions

extension (conn: DuckDBConnection)
def executeQueryIO(sql: String): IO[DuckDBResultSet]

Executes a SQL SELECT query and returns the result set wrapped in IO.

Executes a SQL SELECT query and returns the result set wrapped in IO.

Value parameters

sql

The SQL SELECT statement to execute.

Attributes

Returns

An IO[DuckDBResultSet]. The caller is responsible for closing the result set.

def executeUpdateIO(sql: String): IO[Int]

Executes a SQL update statement (INSERT, UPDATE, DELETE, DDL) and returns the affected row count wrapped in IO.

Executes a SQL update statement (INSERT, UPDATE, DELETE, DDL) and returns the affected row count wrapped in IO.

Value parameters

sql

The SQL statement to execute.

Attributes

Returns

An IO[Int] with the number of affected rows.

def prepareBatchIO(sql: String): IO[DuckDBBatch]

Creates a batch wrapped in IO.

Creates a batch wrapped in IO.

Value parameters

sql

The SQL statement to prepare for batch execution.

Attributes

Returns

An IO[DuckDBBatch]. The caller is responsible for closing the batch.

def prepareStatementIO(sql: String): IO[DuckDBPreparedStatement]

Creates a prepared statement wrapped in IO.

Creates a prepared statement wrapped in IO.

Value parameters

sql

The SQL statement to prepare.

Attributes

Returns

An IO[DuckDBPreparedStatement]. The caller is responsible for closing the statement.

def withBatchIO[T](sql: String)(block: DuckDBBatch => IO[T]): IO[T]

Executes a block with a batch that is automatically closed.

Executes a block with a batch that is automatically closed.

Type parameters

T

The result type.

Value parameters

block

A function receiving the batch and returning an IO[T].

sql

The SQL statement to prepare for batch execution.

Attributes

Returns

An IO[T] with the result of the block.

def withPreparedStatementIO[T](sql: String)(block: DuckDBPreparedStatement => IO[T]): IO[T]

Executes a block with a prepared statement that is automatically closed.

Executes a block with a prepared statement that is automatically closed.

Type parameters

T

The result type.

Value parameters

block

A function receiving the prepared statement and returning an IO[T].

sql

The SQL statement to prepare.

Attributes

Returns

An IO[T] with the result of the block.

def withTransactionIO[T](block: DuckDBConnection => IO[T]): IO[T]

Executes a block within a database transaction.

Executes a block within a database transaction.

Disables auto-commit before running the block. On success, commits the transaction. On failure (any raised error), rolls back the transaction. Auto-commit is restored to true in a guarantee finalizer regardless of outcome.

Type parameters

T

The result type.

Value parameters

block

A function receiving this connection and returning an IO[T].

Attributes

Returns

An IO[T] that commits on success or rolls back on error.