Closed travis-leith closed 3 years ago
I am wondering about this code
var result = PlatformIndependentBindings.NativeMethods.DuckDBOpen(inMemory ? null : filename, out duckDBDatabase);
if (result.IsSuccess())
{
result = PlatformIndependentBindings.NativeMethods.DuckDBConnect(duckDBDatabase, out NativeConnection);
if (!result.IsSuccess())
{
duckDBDatabase.Dispose();
throw new DuckDBException("DuckDBConnect failed", result);
}
}
else
{
throw new DuckDBException("DuckDBOpen failed", result);
}
Maybe duckDBDatabase
should be an object the user creates once for an application and then multiple connections can be spawned from it.
I think you are right. The C Api says:
With the duckdb_database handle, you can create one or many duckdb_connection using duckdb_connect(). While connections should be thread-safe, they will be locked during querying. It is therefore recommended that each thread uses its own connection.
The following code
raises an error.
According to the c++ api docs, concurrent connections are allowed.
This one might be tricky to solve.