Connection constructor

Connection(
  1. String path, [
  2. Config? config
])

Implementation

Connection(this.path, [this.config]) {
  init();
  final ptrPath = path.toNativeUtf8().cast<Char>();

  if (config != null) {
    setConfig();
    if (bindings.duckdb_open_ext(ptrPath, ptrDb, ptrConfig.value, nullptr) ==
        duckdb_state.DuckDBError) {
      throw StateError('Error opening the Db');
    }
  } else {
    if (bindings.duckdb_open(ptrPath, ptrDb) == duckdb_state.DuckDBError) {
      throw StateError('Error opening the Db');
    }
  }

  if (bindings.duckdb_connect(ptrDb.value, ptrCon) ==
      duckdb_state.DuckDBError) {
    throw StateError('Error connecting to the Db');
  }
}