src/config

DuckDB has a number of configuration options that can be used to change the behavior of the system. The configuration options can be set using either the SET statement or the PRAGMA statement. They can be reset to their original values using the RESET statement. The values of configuration options can be queried via the current_setting() scalar function or using the duckdb_settings() table function.

Types

Config = distinct ptr duckdb_config
ConfigValues = Table[string, string]

Procs

proc `=copy`(a: var Config; b: Config) {.error: "Config cannot be copied".}
proc `=destroy`(conf: Config) {....raises: [], tags: [], forbids: [].}
proc `=dup`(cf: Config): Config {.error: "Config cannot be duplicated".}
proc newConfig(): Config {....raises: [OperationError], tags: [], forbids: [].}
Initializes an empty configuration object that can be used to provide start-up options for the DuckDB instance

Example:

import nimdrake

let conf = newConfig()
proc newConfig(values: ConfigValues): Config {....raises: [OperationError],
    tags: [], forbids: [].}
Initializes a configuration object from a table, used to provide start-up options for the DuckDB instance

Example:

import std/tables
import nimdrake

let conf = newConfig({"threads": "3"}.toTable)

let con = newDatabase(conf).connect()
let outcome =
  con.execute("SELECT current_setting('threads') AS threads;").fetchall()
assert outcome[0].valueBigint == @[3'i64]
proc setConfig(config: Config; name: string; option: string) {.
    ...raises: [OperationError], tags: [], forbids: [].}
Sets the specified option for the specified configuration. The configuration option is indicated by name. To obtain a list of config options, see duckdb_get_config_flag. This can fail(raises OperationError) if either the name is invalid, or if the value provided for the option is invalid.

Example:

import nimdrake

let conf = newConfig()
conf.setConfig("threads", "8")

let con = newDatabase(conf).connect()
let outcome =
  con.execute("SELECT current_setting('threads') AS threads;").fetchall()
assert outcome[0].valueBigint == @[8'i64]

conf.setConfig("threads", "2")

let con2 = newDatabase(conf).connect()
let outcome2 =
  con2.execute("SELECT current_setting('threads') AS threads;").fetchall()
assert outcome2[0].valueBigint == @[2'i64]

Converters

converter toBase(c: Config): duckdb_config {....raises: [], tags: [], forbids: [].}
converter toBase(c: ptr Config): ptr duckdb_config {....raises: [], tags: [],
    forbids: [].}