Class DuckDBConnection
public class DuckDBConnection : DbConnection, IComponent, IDbConnection, IDisposable, IAsyncDisposable
- Inheritance
-
DuckDBConnection
- Implements
- Inherited Members
Constructors
DuckDBConnection()
public DuckDBConnection()
DuckDBConnection(string)
public DuckDBConnection(string connectionString)
Parameters
connectionStringstring
Properties
ConnectionString
When overridden in a derived class, gets or sets the string used to open the connection.
[AllowNull]
public override string ConnectionString { get; set; }
Property Value
- string
The connection string used to establish the initial connection. The exact contents of the connection string depend on the specific data source for this connection. The default value is an empty string.
DataSource
When overridden in a derived class, gets the name of the database server to which to connect.
public override string DataSource { get; }
Property Value
- string
The name of the database server to which to connect. The default value is an empty string.
Database
When overridden in a derived class, gets the name of the current database after a connection is opened, or the database name specified in the connection string before the connection is opened.
public override string Database { get; }
Property Value
- string
The name of the current database or the name of the database to be used after a connection is opened. The default value is an empty string.
DbProviderFactory
Gets the DbProviderFactory for this DbConnection.
protected override DbProviderFactory? DbProviderFactory { get; }
Property Value
- DbProviderFactory
A set of methods for creating instances of a provider's implementation of the data source classes.
NativeConnection
Returns the native connection object that can be used to call DuckDB C API functions.
public DuckDBNativeConnection NativeConnection { get; }
Property Value
ServerVersion
When overridden in a derived class, gets a string that represents the version of the server to which the object is connected.
public override string ServerVersion { get; }
Property Value
- string
The version of the database. The format of the string returned depends on the specific type of connection you are using.
Exceptions
- InvalidOperationException
ServerVersion was called while the returned Task was not completed and the connection was not opened after a call to System.Data.Common.DbConnection.OpenAsync*.
State
Gets a string that describes the state of the connection.
public override ConnectionState State { get; }
Property Value
- ConnectionState
The state of the connection. The format of the string returned depends on the specific type of connection you are using.
Methods
BeginDbTransaction(IsolationLevel)
When overridden in a derived class, starts a database transaction.
protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
Parameters
isolationLevelIsolationLevelOne of the enumeration values that specifies the isolation level for the transaction to use.
Returns
- DbTransaction
An object representing the new transaction.
BeginTransaction()
public DuckDBTransaction BeginTransaction()
Returns
ChangeDatabase(string)
When overridden in a derived class, changes the current database for an open connection.
public override void ChangeDatabase(string databaseName)
Parameters
databaseNamestringThe name of the database for the connection to use.
Close()
When overridden in a derived class, closes the connection to the database.
public override void Close()
CreateAppender(string)
public DuckDBAppender CreateAppender(string table)
Parameters
tablestring
Returns
CreateAppender(string?, string)
public DuckDBAppender CreateAppender(string? schema, string table)
Parameters
Returns
CreateAppender(string?, string?, string)
public DuckDBAppender CreateAppender(string? catalog, string? schema, string table)
Parameters
Returns
CreateAppender<T, TMap>(string)
Creates a type-safe appender using an AppenderMap for property-to-column mappings.
public DuckDBMappedAppender<T, TMap> CreateAppender<T, TMap>(string table) where TMap : DuckDBAppenderMap<T>, new()
Parameters
tablestringThe table name
Returns
- DuckDBMappedAppender<T, TMap>
A type-safe mapped appender
Type Parameters
TThe type to append
TMapThe AppenderMap type defining the mappings
CreateAppender<T, TMap>(string?, string)
Creates a type-safe appender using an AppenderMap for property-to-column mappings.
public DuckDBMappedAppender<T, TMap> CreateAppender<T, TMap>(string? schema, string table) where TMap : DuckDBAppenderMap<T>, new()
Parameters
Returns
- DuckDBMappedAppender<T, TMap>
A type-safe mapped appender
Type Parameters
TThe type to append
TMapThe AppenderMap type defining the mappings
CreateAppender<T, TMap>(string?, string?, string)
Creates a type-safe appender using an AppenderMap for property-to-column mappings.
public DuckDBMappedAppender<T, TMap> CreateAppender<T, TMap>(string? catalog, string? schema, string table) where TMap : DuckDBAppenderMap<T>, new()
Parameters
Returns
- DuckDBMappedAppender<T, TMap>
A type-safe mapped appender
Type Parameters
TThe type to append
TMapThe AppenderMap type defining the mappings
CreateCommand()
public virtual DuckDBCommand CreateCommand()
Returns
CreateDbCommand()
When overridden in a derived class, creates and returns a DbCommand object associated with the current connection.
protected override DbCommand CreateDbCommand()
Returns
Dispose(bool)
Releases the unmanaged resources used by the Component and optionally releases the managed resources.
protected override void Dispose(bool disposing)
Parameters
disposingbooltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
Duplicate()
public DuckDBConnection Duplicate()
Returns
GetQueryProgress()
public DuckDBQueryProgress GetQueryProgress()
Returns
GetSchema()
Returns schema information for the data source of this DbConnection.
public override DataTable GetSchema()
Returns
GetSchema(string)
Returns schema information for the data source of this DbConnection using the specified string for the schema name.
public override DataTable GetSchema(string collectionName)
Parameters
collectionNamestringSpecifies the name of the schema to return.
Returns
Exceptions
- ArgumentException
collectionNameis specified as null.
GetSchema(string, string?[]?)
Returns schema information for the data source of this DbConnection using the specified string for the schema name and the specified string array for the restriction values.
public override DataTable GetSchema(string collectionName, string?[]? restrictionValues)
Parameters
collectionNamestringSpecifies the name of the schema to return.
restrictionValuesstring[]Specifies a set of restriction values for the requested schema.
Returns
Exceptions
- ArgumentException
collectionNameis specified as null.
Open()
When overridden in a derived class, opens a database connection with the settings specified by the ConnectionString.
public override void Open()
RegisterScalarFunction<TResult>(string, Action<IDuckDBDataWriter, ulong>, ScalarFunctionOptions?)
public void RegisterScalarFunction<TResult>(string name, Action<IDuckDBDataWriter, ulong> action, ScalarFunctionOptions? options = null)
Parameters
namestringactionAction<IDuckDBDataWriter, ulong>optionsScalarFunctionOptions
Type Parameters
TResult
RegisterScalarFunction<T, TResult>(string, Action<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong>, ScalarFunctionOptions?, bool)
public void RegisterScalarFunction<T, TResult>(string name, Action<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong> action, ScalarFunctionOptions? options = null, bool @params = false)
Parameters
namestringactionAction<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong>optionsScalarFunctionOptionsparamsbool
Type Parameters
TTResult
RegisterScalarFunction<T1, T2, TResult>(string, Action<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong>, ScalarFunctionOptions?)
public void RegisterScalarFunction<T1, T2, TResult>(string name, Action<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong> action, ScalarFunctionOptions? options = null)
Parameters
namestringactionAction<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong>optionsScalarFunctionOptions
Type Parameters
T1T2TResult
RegisterScalarFunction<T1, T2, T3, TResult>(string, Action<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong>, ScalarFunctionOptions?)
public void RegisterScalarFunction<T1, T2, T3, TResult>(string name, Action<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong> action, ScalarFunctionOptions? options = null)
Parameters
namestringactionAction<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong>optionsScalarFunctionOptions
Type Parameters
T1T2T3TResult
RegisterScalarFunction<T1, T2, T3, T4, TResult>(string, Action<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong>, ScalarFunctionOptions?)
public void RegisterScalarFunction<T1, T2, T3, T4, TResult>(string name, Action<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong> action, ScalarFunctionOptions? options = null)
Parameters
namestringactionAction<IReadOnlyList<IDuckDBDataReader>, IDuckDBDataWriter, ulong>optionsScalarFunctionOptions
Type Parameters
T1T2T3T4TResult
RegisterTableFunction(string, Func<TableFunction>, Action<object?, IDuckDBDataWriter[], ulong>)
public void RegisterTableFunction(string name, Func<TableFunction> resultCallback, Action<object?, IDuckDBDataWriter[], ulong> mapperCallback)
Parameters
namestringresultCallbackFunc<TableFunction>mapperCallbackAction<object, IDuckDBDataWriter[], ulong>
RegisterTableFunction(string, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction>, Action<object?, IDuckDBDataWriter[], ulong>, params DuckDBType[])
public void RegisterTableFunction(string name, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction> resultCallback, Action<object?, IDuckDBDataWriter[], ulong> mapperCallback, params DuckDBType[] parameterTypes)
Parameters
namestringresultCallbackFunc<IReadOnlyList<IDuckDBValueReader>, TableFunction>mapperCallbackAction<object, IDuckDBDataWriter[], ulong>parameterTypesDuckDBType[]
RegisterTableFunction<T>(string, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction>, Action<object?, IDuckDBDataWriter[], ulong>)
public void RegisterTableFunction<T>(string name, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction> resultCallback, Action<object?, IDuckDBDataWriter[], ulong> mapperCallback)
Parameters
namestringresultCallbackFunc<IReadOnlyList<IDuckDBValueReader>, TableFunction>mapperCallbackAction<object, IDuckDBDataWriter[], ulong>
Type Parameters
T
RegisterTableFunction<T1, T2>(string, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction>, Action<object?, IDuckDBDataWriter[], ulong>)
public void RegisterTableFunction<T1, T2>(string name, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction> resultCallback, Action<object?, IDuckDBDataWriter[], ulong> mapperCallback)
Parameters
namestringresultCallbackFunc<IReadOnlyList<IDuckDBValueReader>, TableFunction>mapperCallbackAction<object, IDuckDBDataWriter[], ulong>
Type Parameters
T1T2
RegisterTableFunction<T1, T2, T3>(string, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction>, Action<object?, IDuckDBDataWriter[], ulong>)
public void RegisterTableFunction<T1, T2, T3>(string name, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction> resultCallback, Action<object?, IDuckDBDataWriter[], ulong> mapperCallback)
Parameters
namestringresultCallbackFunc<IReadOnlyList<IDuckDBValueReader>, TableFunction>mapperCallbackAction<object, IDuckDBDataWriter[], ulong>
Type Parameters
T1T2T3
RegisterTableFunction<T1, T2, T3, T4>(string, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction>, Action<object?, IDuckDBDataWriter[], ulong>)
public void RegisterTableFunction<T1, T2, T3, T4>(string name, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction> resultCallback, Action<object?, IDuckDBDataWriter[], ulong> mapperCallback)
Parameters
namestringresultCallbackFunc<IReadOnlyList<IDuckDBValueReader>, TableFunction>mapperCallbackAction<object, IDuckDBDataWriter[], ulong>
Type Parameters
T1T2T3T4
RegisterTableFunction<T1, T2, T3, T4, T5>(string, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction>, Action<object?, IDuckDBDataWriter[], ulong>)
public void RegisterTableFunction<T1, T2, T3, T4, T5>(string name, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction> resultCallback, Action<object?, IDuckDBDataWriter[], ulong> mapperCallback)
Parameters
namestringresultCallbackFunc<IReadOnlyList<IDuckDBValueReader>, TableFunction>mapperCallbackAction<object, IDuckDBDataWriter[], ulong>
Type Parameters
T1T2T3T4T5
RegisterTableFunction<T1, T2, T3, T4, T5, T6>(string, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction>, Action<object?, IDuckDBDataWriter[], ulong>)
public void RegisterTableFunction<T1, T2, T3, T4, T5, T6>(string name, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction> resultCallback, Action<object?, IDuckDBDataWriter[], ulong> mapperCallback)
Parameters
namestringresultCallbackFunc<IReadOnlyList<IDuckDBValueReader>, TableFunction>mapperCallbackAction<object, IDuckDBDataWriter[], ulong>
Type Parameters
T1T2T3T4T5T6
RegisterTableFunction<T1, T2, T3, T4, T5, T6, T7>(string, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction>, Action<object?, IDuckDBDataWriter[], ulong>)
public void RegisterTableFunction<T1, T2, T3, T4, T5, T6, T7>(string name, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction> resultCallback, Action<object?, IDuckDBDataWriter[], ulong> mapperCallback)
Parameters
namestringresultCallbackFunc<IReadOnlyList<IDuckDBValueReader>, TableFunction>mapperCallbackAction<object, IDuckDBDataWriter[], ulong>
Type Parameters
T1T2T3T4T5T6T7
RegisterTableFunction<T1, T2, T3, T4, T5, T6, T7, T8>(string, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction>, Action<object?, IDuckDBDataWriter[], ulong>)
public void RegisterTableFunction<T1, T2, T3, T4, T5, T6, T7, T8>(string name, Func<IReadOnlyList<IDuckDBValueReader>, TableFunction> resultCallback, Action<object?, IDuckDBDataWriter[], ulong> mapperCallback)
Parameters
namestringresultCallbackFunc<IReadOnlyList<IDuckDBValueReader>, TableFunction>mapperCallbackAction<object, IDuckDBDataWriter[], ulong>
Type Parameters
T1T2T3T4T5T6T7T8