DuckDB.Appender
— TypeAn appender object that can be used to append rows to an existing table.
- DateTime objects in Julia are stored in milliseconds since the Unix epoch but are converted to microseconds when stored in duckdb.
- Time objects in Julia are stored in nanoseconds since midnight but are converted to microseconds when stored in duckdb.
- Missing and Nothing are stored as NULL in duckdb, but will be converted to Missing when the data is queried back.
Example
using DuckDB, DataFrames, Dates
db = DuckDB.DB()
# create a table
DBInterface.execute(db, "CREATE OR REPLACE TABLE data(id INT PRIMARY KEY, value FLOAT, timestamp TIMESTAMP, date DATE)")
# data to insert
len = 100
df = DataFrames.DataFrame(id=collect(1:len),
value=rand(len),
timestamp=Dates.now() + Dates.Second.(1:len),
date=Dates.today() + Dates.Day.(1:len))
# append data by row
appender = DuckDB.Appender(db, "data")
for i in eachrow(df)
for j in i
DuckDB.append(appender, j)
end
DuckDB.end_row(appender)
end
# flush the appender after all rows
DuckDB.flush(appender)
DuckDB.close(appender)
DuckDB.Config
— TypeConfiguration object
DuckDB.Connection
— TypeA connection object to a DuckDB database.
Transaction contexts are local to a single connection.
A connection can only run a single query concurrently. It is possible to open multiple connections to a single DuckDB database instance. Multiple connections can run multiple queries concurrently.
DuckDB.DB
— TypeA DuckDB database object.
By default a DuckDB database object has an open connection object (db.mainconnection). When the database object is used directly in queries, it is actually the underlying mainconnection that is used.
It is possible to open new connections to a single database instance using DBInterface.connect(db).
DuckDB.DataChunk
— TypeDuckDB data chunk
DuckDB.DuckDBHandle
— TypeInternal DuckDB database handle.
DuckDB.LogicalType
— TypeDuckDB type
DuckDB.TableFunction
— TypeDuckDB table function
DuckDB.ValidityMask
— TypeDuckDB validity mask
DuckDB.Value
— TypeDuckDB value
DuckDB.Vec
— TypeDuckDB vector
DuckDB.duckdb_date
— TypeDays are stored as days since 1970-01-01
Use the duckdbfromdate/duckdbtodate function to extract individual information
DuckDB.duckdb_hugeint
— TypeHugeints are composed in a (lower, upper) component
The value of the hugeint is upper * 2^64 + lower
For easy usage, the functions duckdbhugeinttodouble/duckdbdoubletohugeint are recommended
DuckDB.duckdb_time
— TypeTime is stored as microseconds since 00:00:00
Use the duckdbfromtime/duckdbtotime function to extract individual information
DuckDB.duckdb_timestamp
— TypeTimestamps are stored as microseconds since 1970-01-01
Use the duckdbfromtimestamp/duckdbtotimestamp function to extract individual information
DBInterface.execute
— MethodDBInterface.execute(db::DuckDB.DB, sql::String, [params])
DBInterface.execute(stmt::SQLite.Stmt, [params])
Bind any positional (params
as Vector
or Tuple
) or named (params
as NamedTuple
or Dict
) parameters to an SQL statement, given by db
and sql
or as an already prepared statement stmt
, execute the query and return an iterator of result rows.
Note that the returned result row iterator only supports a single-pass, forward-only iteration of the result rows. Calling SQLite.reset!(result)
will re-execute the query and reset the iterator back to the beginning.
The resultset iterator supports the Tables.jl interface, so results can be collected in any Tables.jl-compatible sink, like DataFrame(results)
, CSV.write("results.csv", results)
, etc.
DBInterface.lastrowid
— MethodReturn the last row insert id from the executed statement
DBInterface.prepare
— MethodDBInterface.prepare(db::DuckDB.DB, sql::AbstractString)
Prepare an SQL statement given as a string in the DuckDB database; returns a DuckDB.Stmt
object. See DBInterface.execute
(@ref) for information on executing a prepared statement and passing parameters to bind. A DuckDB.Stmt
object can be closed (resources freed) using DBInterface.close!
(@ref).
DuckDB.begin_transaction
— FunctionDuckDB.begin(db)
begin a transaction
DuckDB.commit
— FunctionDuckDB.commit(db)
commit a transaction
DuckDB.duckdb_add_replacement_scan
— MethodAdd a replacement scan definition to the specified database
- db: The database object to add the replacement scan to
- replacement: The replacement scan callback
- extra_data: Extra data that is passed back into the specified callback
- delete_callback: The delete callback to call on the extra data, if any
DuckDB.duckdb_append_blob
— MethodAppend a blob value to the appender. DUCKDBAPI duckdbstate duckdbappendblob(duckdbappender appender, const void *data, idxt length);
DuckDB.duckdb_append_bool
— MethodAppend a bool value to the appender. DUCKDBAPI duckdbstate duckdbappendbool(duckdb_appender appender, bool value);
DuckDB.duckdb_append_date
— MethodAppend a duckdbdate value to the appender. DUCKDBAPI duckdbstate duckdbappenddate(duckdbappender appender, duckdb_date value);
DuckDB.duckdb_append_double
— MethodAppend a double value to the appender. DUCKDBAPI duckdbstate duckdbappenddouble(duckdb_appender appender, double value);
DuckDB.duckdb_append_float
— MethodAppend a float value to the appender. DUCKDBAPI duckdbstate duckdbappendfloat(duckdb_appender appender, float value);
DuckDB.duckdb_append_hugeint
— MethodAppend a duckdbhugeint value to the appender. DUCKDBAPI duckdbstate duckdbappendhugeint(duckdbappender appender, duckdb_hugeint value);
DuckDB.duckdb_append_int16
— MethodAppend an int16t value to the appender. DUCKDBAPI duckdbstate duckdbappendint16(duckdbappender appender, int16_t value);
DuckDB.duckdb_append_int32
— MethodAppend an int32t value to the appender. DUCKDBAPI duckdbstate duckdbappendint32(duckdbappender appender, int32_t value);
DuckDB.duckdb_append_int64
— MethodAppend an int64t value to the appender. DUCKDBAPI duckdbstate duckdbappendint64(duckdbappender appender, int64_t value);
DuckDB.duckdb_append_int8
— MethodAppend an int8t value to the appender. DUCKDBAPI duckdbstate duckdbappendint8(duckdbappender appender, int8_t value);
DuckDB.duckdb_append_interval
— MethodAppend a duckdbinterval value to the appender. DUCKDBAPI duckdbstate duckdbappendinterval(duckdbappender appender, duckdb_interval value);
DuckDB.duckdb_append_null
— MethodAppend a NULL value to the appender (of any type). DUCKDBAPI duckdbstate duckdbappendnull(duckdb_appender appender);
DuckDB.duckdb_append_time
— MethodAppend a duckdbtime value to the appender. DUCKDBAPI duckdbstate duckdbappendtime(duckdbappender appender, duckdb_time value);
DuckDB.duckdb_append_timestamp
— MethodAppend a duckdbtimestamp value to the appender. DUCKDBAPI duckdbstate duckdbappendtimestamp(duckdbappender appender, duckdb_timestamp value);
DuckDB.duckdb_append_uhugeint
— MethodAppend a duckdbuhugeint value to the appender. DUCKDBAPI duckdbstate duckdbappenduhugeint(duckdbappender appender, duckdb_uhugeint value);
DuckDB.duckdb_append_uint16
— MethodAppend a uint16t value to the appender. DUCKDBAPI duckdbstate duckdbappenduint16(duckdbappender appender, uint16_t value);
DuckDB.duckdb_append_uint32
— MethodAppend a uint32t value to the appender. DUCKDBAPI duckdbstate duckdbappenduint32(duckdbappender appender, uint32_t value);
DuckDB.duckdb_append_uint64
— MethodAppend a uint64t value to the appender. DUCKDBAPI duckdbstate duckdbappenduint64(duckdbappender appender, uint64_t value);
DuckDB.duckdb_append_uint8
— MethodAppend a uint8t value to the appender. DUCKDBAPI duckdbstate duckdbappenduint8(duckdbappender appender, uint8_t value);
DuckDB.duckdb_append_varchar
— MethodAppend a varchar value to the appender. DUCKDBAPI duckdbstate duckdbappendvarchar(duckdb_appender appender, const char *val);
DuckDB.duckdb_append_varchar_length
— MethodAppend a varchar value to the appender. DUCKDBAPI duckdbstate duckdbappendvarcharlength(duckdbappender appender, const char *val, idx_t length);
DuckDB.duckdb_appender_begin_row
— MethodA nop function, provided for backwards compatibility reasons. Does nothing. Only duckdb_appender_end_row
is required. DUCKDBAPI duckdbstate duckdbappenderbeginrow(duckdbappender appender);
DuckDB.duckdb_appender_close
— MethodClose the appender, flushing all intermediate state in the appender to the table and closing it for further appends. This is generally not necessary. Call duckdb_appender_destroy
instead.
- appender: The appender to flush and close.
- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DUCKDBAPI duckdbstate duckdbappenderclose(duckdb_appender appender);
DuckDB.duckdb_appender_create
— MethodCreates an appender object.
- connection: The connection context to create the appender in.
- schema: The schema of the table to append to, or
nullptr
for the default schema. - table: The table name to append to.
- out_appender: The resulting appender object.
- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DUCKDBAPI duckdbstate duckdbappendercreate(duckdbconnection connection, const char *schema, const char *table, duckdbappender *out_appender);
DuckDB.duckdb_appender_destroy
— MethodClose the appender and destroy it. Flushing all intermediate state in the appender to the table, and de-allocating all memory associated with the appender.
- appender: The appender to flush, close and destroy.
- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DUCKDBAPI duckdbstate duckdbappenderdestroy(duckdb_appender *appender);
DuckDB.duckdb_appender_end_row
— MethodFinish the current row of appends. After end_row is called, the next row can be appended.
- appender: The appender.
- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DUCKDBAPI duckdbstate duckdbappenderendrow(duckdbappender appender);
DuckDB.duckdb_appender_error
— MethodReturns the error message associated with the given appender. If the appender has no error message, this returns nullptr
instead. The error message should not be freed. It will be de-allocated when duckdb_appender_destroy
is called.
- appender: The appender to get the error from.
- returns: The error message, or
nullptr
if there is none.
DUCKDBAPI const char *duckdbappendererror(duckdbappender appender);
DuckDB.duckdb_appender_flush
— MethodFlush the appender to the table, forcing the cache of the appender to be cleared and the data to be appended to the base table. This should generally not be used unless you know what you are doing. Instead, call duckdb_appender_destroy
when you are done with the appender.
- appender: The appender to flush.
- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DUCKDBAPI duckdbstate duckdbappenderflush(duckdb_appender appender);
DuckDB.duckdb_bind_add_result_column
— MethodAdds a result column to the output of the table function.
- info: The info object
- name: The name of the column
- type: The logical type of the column
DuckDB.duckdb_bind_blob
— MethodBinds a blob value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindblob(duckdbpreparedstatement preparedstatement, idxt paramidx, const void *data, idxt length);
DuckDB.duckdb_bind_boolean
— MethodBinds a bool value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindboolean(duckdbpreparedstatement preparedstatement, idxt param_idx, bool val);
DuckDB.duckdb_bind_date
— MethodBinds a duckdbdate value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinddate(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_date val);
DuckDB.duckdb_bind_double
— MethodBinds a double value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinddouble(duckdbpreparedstatement preparedstatement, idxt param_idx, double val);
DuckDB.duckdb_bind_float
— MethodBinds a float value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindfloat(duckdbpreparedstatement preparedstatement, idxt param_idx, float val);
DuckDB.duckdb_bind_get_extra_info
— MethodRetrieves the extra info of the function as set in duckdb_table_function_set_extra_info
- info: The info object
- returns: The extra info
DuckDB.duckdb_bind_get_parameter
— MethodRetrieves the parameter at the given index.
The result must be destroyed with duckdb_destroy_value
.
- info: The info object
- index: The index of the parameter to get
- returns: The value of the parameter. Must be destroyed with
duckdb_destroy_value
.
DuckDB.duckdb_bind_get_parameter_count
— MethodRetrieves the number of regular (non-named) parameters to the function.
- info: The info object
- returns: The number of parameters
DuckDB.duckdb_bind_hugeint
— MethodBinds a duckdbhugeint value to the prepared statement at the specified index. */ DUCKDBAPI duckdbstate duckdbbindhugeint(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_hugeint val);
DuckDB.duckdb_bind_int16
— MethodBinds an int16t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindint16(duckdbpreparedstatement preparedstatement, idxt paramidx, int16_t val);
DuckDB.duckdb_bind_int32
— MethodBinds an int32t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindint32(duckdbpreparedstatement preparedstatement, idxt paramidx, int32_t val);
DuckDB.duckdb_bind_int64
— MethodBinds an int64t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindint64(duckdbpreparedstatement preparedstatement, idxt paramidx, int64_t val);
DuckDB.duckdb_bind_int8
— MethodBinds an int8t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindint8(duckdbpreparedstatement preparedstatement, idxt paramidx, int8_t val);
DuckDB.duckdb_bind_interval
— MethodBinds a duckdbinterval value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindinterval(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_interval val);
DuckDB.duckdb_bind_null
— MethodBinds a NULL value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindnull(duckdbpreparedstatement preparedstatement, idxt param_idx);
DuckDB.duckdb_bind_set_bind_data
— MethodRetrieves the parameter at the given index.
The result must be destroyed with duckdb_destroy_value
.
- info: The info object
- index: The index of the parameter to get
- returns: The value of the parameter. Must be destroyed with
duckdb_destroy_value
.
DuckDB.duckdb_bind_set_cardinality
— MethodSets the cardinality estimate for the table function, used for optimization.
- info: The bind data object.
- is_exact: Whether or not the cardinality estimate is exact, or an approximation
DuckDB.duckdb_bind_set_error
— MethodReport that an error has occurred during bind.
- info: The info object
- error: The error message
DuckDB.duckdb_bind_time
— MethodBinds a duckdbtime value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindtime(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_time val);
DuckDB.duckdb_bind_timestamp
— MethodBinds a duckdbtimestamp value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindtimestamp(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_timestamp val);
DuckDB.duckdb_bind_uhugeint
— MethodBinds an duckdbuhugeint value to the prepared statement at the specified index. */ DUCKDBAPI duckdbstate duckdbbindhugeint(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_uhugeint val);
DuckDB.duckdb_bind_uint16
— MethodBinds an uint16t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinduint16(duckdbpreparedstatement preparedstatement, idxt paramidx, uint16_t val);
DuckDB.duckdb_bind_uint32
— MethodBinds an uint32t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinduint32(duckdbpreparedstatement preparedstatement, idxt paramidx, uint32_t val);
DuckDB.duckdb_bind_uint64
— MethodBinds an uint64t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinduint64(duckdbpreparedstatement preparedstatement, idxt paramidx, uint64_t val);
DuckDB.duckdb_bind_uint8
— MethodBinds an uint8t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinduint8(duckdbpreparedstatement preparedstatement, idxt paramidx, uint8_t val);
DuckDB.duckdb_bind_varchar
— MethodBinds a null-terminated varchar value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindvarchar(duckdbpreparedstatement preparedstatement, idxt param_idx, const char *val);
DuckDB.duckdb_bind_varchar_length
— MethodBinds a varchar value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindvarcharlength(duckdbpreparedstatement preparedstatement, idxt paramidx, const char *val, idx_t length);
DuckDB.duckdb_close
— Methodduckdb_close(database)
Closes the specified database and de-allocates all memory allocated for that database. This should be called after you are done with any database allocated through duckdb_open
. Note that failing to call duckdb_close
(in case of e.g. a program crash) will not cause data corruption. Still it is recommended to always correctly close a database object after you are done with it.
database
: The database object to shut down.
DuckDB.duckdb_column_count
— Methodduckdb_column_count(result)
Returns the number of columns present in a the result object.
result
: The result object.- returns: The number of columns present in the result object.
DuckDB.duckdb_column_data
— Methodduckdb_column_data(result,col)
Returns the data of a specific column of a result in columnar format. This is the fastest way of accessing data in a query result, as no conversion or type checking must be performed (outside of the original switch). If performance is a concern, it is recommended to use this API over the duckdb_value
functions. The function returns a dense array which contains the result data. The exact type stored in the array depends on the corresponding duckdbtype (as provided by `duckdbcolumntype). For the exact type by which the data should be accessed, see the comments in [the types section](types) or the
DUCKDBTYPEenum. For example, for a column of type
DUCKDBTYPEINTEGER`, rows can be accessed in the following manner:
int32_t *data = (int32_t *) duckdb_column_data(&result, 0);
printf("Data for row %d: %d\n", row, data[row]);
result
: The result object to fetch the column data from.col
: The column index.- returns: The column data of the specified column.
DuckDB.duckdb_column_logical_type
— MethodReturns the logical column type of the specified column.
The return type of this call should be destroyed with duckdb_destroy_logical_type
.
Returns NULL
if the column is out of range.
- result: The result object to fetch the column type from.
- col: The column index.
- returns: The logical column type of the specified column.
DuckDB.duckdb_column_name
— Methodduckdb_column_name(result,col)
Returns the column name of the specified column. The result should not need be freed; the column names will automatically be destroyed when the result is destroyed. Returns NULL
if the column is out of range.
result
: The result object to fetch the column name from.col
: The column index.- returns: The column name of the specified column.
DuckDB.duckdb_column_type
— Methodduckdb_column_type(result,col)
Returns the column type of the specified column. Returns DUCKDB_TYPE_INVALID
if the column is out of range.
result
: The result object to fetch the column type from.col
: The column index.- returns: The column type of the specified column.
DuckDB.duckdb_config_count
— Methodduckdb_config_count()
This returns the total amount of configuration options available for usage with duckdb_get_config_flag
. This should not be called in a loop as it internally loops over all the options.
- returns: The amount of config options available.
DuckDB.duckdb_connect
— Methodduckdb_connect(database, out_connection)
Opens a connection to a database. Connections are required to query the database, and store transactional state associated with the connection.
database
: The database file to connect to.out_connection
: The result connection object.- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DuckDB.duckdb_create_config
— Methodduckdb_create_config(config)
Initializes an empty configuration object that can be used to provide start-up options for the DuckDB instance through duckdb_open_ext
. This will always succeed unless there is a malloc failure.
out_config
: The result configuration object.- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DuckDB.duckdb_create_data_chunk
— MethodCreates an empty DataChunk with the specified set of types.
- types: An array of types of the data chunk.
- column_count: The number of columns.
- returns: The data chunk.
DuckDB.duckdb_create_decimal_type
— MethodCreates a duckdb_logical_type
of type decimal with the specified width and scale The resulting type should be destroyed with duckdb_destroy_logical_type
.
- width: The width of the decimal type
- scale: The scale of the decimal type
- returns: The logical type.
DuckDB.duckdb_create_int64
— MethodCreates a value from an int64
- value: The bigint value
- returns: The value. This must be destroyed with
duckdb_destroy_value
.
DuckDB.duckdb_create_logical_type
— MethodCreates a duckdb_logical_type
from a standard primitive type. The resulting type should be destroyed with duckdb_destroy_logical_type
.
This should not be used with DUCKDB_TYPE_DECIMAL
.
- type: The primitive type to create.
- returns: The logical type type.
DuckDB.duckdb_create_table_function
— MethodCreates a new empty table function.
The return value should be destroyed with duckdb_destroy_table_function
.
- returns: The table function object.
DuckDB.duckdb_create_task_state
— MethodCreates a task state that can be used with duckdbexecutetasksstate to execute tasks until duckdbfinish_execution is called on the state.
duckdbdestroystate should be called on the result in order to free memory.
- returns: The task state that can be used with duckdbexecutetasks_state.
DuckDB.duckdb_create_varchar
— MethodCreates a value from a null-terminated string
- value: The null-terminated string
- returns: The value. This must be destroyed with
duckdb_destroy_value
.
DuckDB.duckdb_create_varchar_length
— MethodCreates a value from a string
- value: The text
- length: The length of the text
- returns: The value. This must be destroyed with
duckdb_destroy_value
.
DuckDB.duckdb_data_chunk_get_column_count
— MethodRetrieves the number of columns in a data chunk.
- chunk: The data chunk to get the data from
- returns: The number of columns in the data chunk
DuckDB.duckdb_data_chunk_get_size
— MethodRetrieves the current number of tuples in a data chunk.
- chunk: The data chunk to get the data from
- returns: The number of tuples in the data chunk
DuckDB.duckdb_data_chunk_get_vector
— MethodRetrieves the vector at the specified column index in the data chunk.
The pointer to the vector is valid for as long as the chunk is alive. It does NOT need to be destroyed.
- chunk: The data chunk to get the data from
- returns: The vector
DuckDB.duckdb_data_chunk_reset
— MethodResets a data chunk, clearing the validity masks and setting the cardinality of the data chunk to 0.
- chunk: The data chunk to reset.
DuckDB.duckdb_data_chunk_set_size
— MethodSets the current number of tuples in a data chunk.
- chunk: The data chunk to set the size in
- size: The number of tuples in the data chunk
DuckDB.duckdb_decimal_internal_type
— MethodRetrieves the internal storage type of a decimal type.
- type: The logical type object
- returns: The internal type of the decimal type
DuckDB.duckdb_decimal_scale
— MethodRetrieves the scale of a decimal type.
- type: The logical type object
- returns: The scale of the decimal type
DuckDB.duckdb_decimal_width
— MethodRetrieves the width of a decimal type.
- type: The logical type object
- returns: The width of the decimal type
DuckDB.duckdb_destroy_config
— Methodduckdb_destroy_config(config)
Destroys the specified configuration option and de-allocates all memory allocated for the object.
config
: The configuration object to destroy.
DuckDB.duckdb_destroy_data_chunk
— MethodDestroys the data chunk and de-allocates all memory allocated for that chunk.
- chunk: The data chunk to destroy.
DuckDB.duckdb_destroy_logical_type
— MethodDestroys the logical type and de-allocates all memory allocated for that type.
- type: The logical type to destroy.
DuckDB.duckdb_destroy_pending
— MethodCloses the pending result and de-allocates all memory allocated for the result.
- pending_result: The pending result to destroy.
DuckDB.duckdb_destroy_prepare
— MethodCloses the prepared statement and de-allocates all memory allocated for that connection.
- prepared_statement: The prepared statement to destroy.
DUCKDBAPI void duckdbdestroyprepare(duckdbpreparedstatement *preparedstatement);
DuckDB.duckdb_destroy_result
— Methodduckdb_destroy_result(result)
Closes the result and de-allocates all memory allocated for that connection.
result
: The result to destroy.
DuckDB.duckdb_destroy_table_function
— MethodDestroys the given table function object.
- table_function: The table function to destroy
DuckDB.duckdb_destroy_task_state
— MethodDestroys the task state returned from duckdbcreatetask_state.
Note that this should not be called while there is an active duckdbexecutetasks_state running on the task state.
- state: The task state to clean up
DuckDB.duckdb_destroy_value
— MethodDestroys the value and de-allocates all memory allocated for that type.
- value: The value to destroy.
DuckDB.duckdb_disconnect
— Methodduckdb_disconnect(connection)
Closes the specified connection and de-allocates all memory allocated for that connection.
connection
: The connection to close.
DuckDB.duckdb_enum_dictionary_size
— MethodRetrieves the dictionary size of the enum type
- type: The logical type object
- returns: The dictionary size of the enum type
DuckDB.duckdb_enum_dictionary_value
— MethodRetrieves the dictionary value at the specified position from the enum.
The result must be freed with duckdb_free
- type: The logical type object
- index: The index in the dictionary
- returns: The string value of the enum type. Must be freed with
duckdb_free
.
DuckDB.duckdb_enum_internal_type
— MethodRetrieves the internal storage type of an enum type.
- type: The logical type object
- returns: The internal type of the enum type
DuckDB.duckdb_execute_n_tasks_state
— MethodExecute DuckDB tasks on this thread.
The thread will keep on executing tasks until either duckdbfinishexecution is called on the state, max_tasks tasks have been executed or there are no more tasks to be executed.
Multiple threads can share the same duckdbtaskstate.
- state: The task state of the executor
- max_tasks: The maximum amount of tasks to execute
- returns: The amount of tasks that have actually been executed
DuckDB.duckdb_execute_pending
— MethodFully execute a pending query result, returning the final query result.
If duckdbpendingexecutetask has been called until DUCKDBPENDINGRESULTREADY was returned, this will return fast. Otherwise, all remaining tasks must be executed first.
- pending_result: The pending result to execute.
- out_result: The result object.
- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DuckDB.duckdb_execute_prepared
— MethodExecutes the prepared statement with the given bound parameters, and returns a materialized query result. This method can be called multiple times for each prepared statement, and the parameters can be modified between calls to this function.
- prepared_statement: The prepared statement to execute.
- out_result: The query result.
- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DUCKDBAPI duckdbstate duckdbexecuteprepared(duckdbpreparedstatement preparedstatement, duckdbresult *out_result);
DuckDB.duckdb_execute_tasks
— MethodExecute DuckDB tasks on this thread.
Will return after max_tasks
have been executed, or if there are no more tasks present.
- database: The database object to execute tasks for
- max_tasks: The maximum amount of tasks to execute
DuckDB.duckdb_execute_tasks_state
— MethodExecute DuckDB tasks on this thread.
The thread will keep on executing tasks forever, until duckdbfinishexecution is called on the state. Multiple threads can share the same duckdbtaskstate.
- database: The database object to execute tasks for
- state: The task state of the executor
DuckDB.duckdb_execution_is_finished
— MethodReturns true if execution of the current query is finished.
- con: The connection on which to check
DuckDB.duckdb_finish_execution
— MethodFinish execution on a specific task.
- state: The task state to finish execution
DuckDB.duckdb_free
— Methodduckdbfree(ptr) Free a value returned from `duckdbmalloc,
duckdbvaluevarcharor
duckdbvalueblob`.
- ptr: The memory region to de-allocate.
DUCKDBAPI void duckdbfree(void *ptr);
DuckDB.duckdb_from_time_tz
— MethodDecompose a TIME_TZ objects into micros and a timezone offset.
Use duckdb_from_time
to further decompose the micros into hour, minute, second and microsecond.
- micros: The time object, as obtained from a
DUCKDB_TYPE_TIME_TZ
column. - out_micros: The microsecond component of the time.
- out_offset: The timezone offset component of the time.
DuckDB.duckdb_function_get_bind_data
— MethodGets the bind data set by duckdb_bind_set_bind_data
during the bind.
Note that the bind data should be considered as read-only. For tracking state, use the init data instead.
- info: The info object
- returns: The bind data object
DuckDB.duckdb_function_get_extra_info
— MethodRetrieves the extra info of the function as set in duckdb_table_function_set_extra_info
- info: The info object
- returns: The extra info
DuckDB.duckdb_function_get_init_data
— MethodGets the init data set by duckdb_init_set_init_data
during the init.
- info: The info object
- returns: The init data object
DuckDB.duckdb_function_get_local_init_data
— MethodGets the init data set by duckdb_init_set_init_data
during the local_init.
- info: The info object
- returns: The init data object
DuckDB.duckdb_function_set_error
— MethodReport that an error has occurred while executing the function.
- info: The info object
- error: The error message
DuckDB.duckdb_get_config_flag
— Methodduckdb_get_config_flag(index,out_name,out_description)
Obtains a human-readable name and description of a specific configuration option. This can be used to e.g. display configuration options. This will succeed unless index
is out of range (i.e. >= duckdb_config_count
). The result name or description MUST NOT be freed.
index
: The index of the configuration option (between 0 andduckdb_config_count
)out_name
: A name of the configuration flag.out_description
: A description of the configuration flag.- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DuckDB.duckdb_get_int64
— MethodObtains an int64 of the given value.
- value: The value
- returns: The int64 value, or 0 if no conversion is possible
DuckDB.duckdb_get_type_id
— MethodRetrieves the type class of a duckdb_logical_type
.
- type: The logical type object
- returns: The type id
DuckDB.duckdb_get_varchar
— MethodObtains a string representation of the given value. The result must be destroyed with duckdb_free
.
- value: The value
- returns: The string value. This must be destroyed with
duckdb_free
.
DuckDB.duckdb_init_get_bind_data
— MethodGets the bind data set by duckdb_bind_set_bind_data
during the bind.
Note that the bind data should be considered as read-only. For tracking state, use the init data instead.
- info: The info object
- returns: The bind data object
DuckDB.duckdb_init_get_column_count
— MethodReturns the number of projected columns.
This function must be used if projection pushdown is enabled to figure out which columns to emit.
- info: The info object
- returns: The number of projected columns.
DuckDB.duckdb_init_get_column_index
— MethodReturns the column index of the projected column at the specified position.
This function must be used if projection pushdown is enabled to figure out which columns to emit.
- info: The info object
- columnindex: The index at which to get the projected column index, from 0..duckdbinitgetcolumn_count(info)
- returns: The column index of the projected column.
DuckDB.duckdb_init_get_extra_info
— MethodRetrieves the extra info of the function as set in duckdb_table_function_set_extra_info
- info: The info object
- returns: The extra info
DuckDB.duckdb_init_set_error
— MethodReport that an error has occurred during init.
- info: The info object
- error: The error message
DuckDB.duckdb_init_set_init_data
— MethodSets the user-provided init data in the init object. This object can be retrieved again during execution.
- info: The info object
- extra_data: The init data object.
- destroy: The callback that will be called to destroy the init data (if any)
DuckDB.duckdb_init_set_max_threads
— MethodSets how many threads can process this table function in parallel (default: 1)
- info: The info object
- max_threads: The maximum amount of threads that can process this table function
DuckDB.duckdb_list_type_child_type
— MethodRetrieves the child type of the given list type.
The result must be freed with duckdb_destroy_logical_type
- type: The logical type object
- returns: The child type of the list type. Must be destroyed with
duckdb_destroy_logical_type
.
DuckDB.duckdb_list_vector_get_child
— MethodRetrieves the child vector of a list vector.
The resulting vector is valid as long as the parent vector is valid.
- vector: The vector
- returns: The child vector
DuckDB.duckdb_list_vector_get_size
— MethodReturns the size of the child vector of the list
- vector: The vector
- returns: The size of the child list
DuckDB.duckdb_malloc
— Methodduckdb_malloc(size)
Allocate size
bytes of memory using the duckdb internal malloc function. Any memory allocated in this manner should be freed using duckdb_free
.
- size: The number of bytes to allocate.
- returns: A pointer to the allocated memory region.
DUCKDBAPI void *duckdbmalloc(size_t size);
DuckDB.duckdb_nparams
— MethodReturns the number of parameters that can be provided to the given prepared statement. Returns 0 if the query was not successfully prepared.
- prepared_statement: The prepared statement to obtain the number of parameters for.
DUCKDBAPI idxt duckdbnparams(duckdbpreparedstatement preparedstatement);
DuckDB.duckdb_nullmask_data
— Methodduckdb_nullmask_data(result,col)
Returns the nullmask of a specific column of a result in columnar format. The nullmask indicates for every row whether or not the corresponding row is NULL
. If a row is NULL
, the values present in the array provided by duckdb_column_data
are undefined.
int32_t *data = (int32_t *) duckdb_column_data(&result, 0);
bool *nullmask = duckdb_nullmask_data(&result, 0);
if (nullmask[row]) {
printf("Data for row %d: NULL
", row);
} else {
printf("Data for row %d: %d
", row, data[row]);
}
result
: The result object to fetch the nullmask from.col
: The column index.- returns: The nullmask of the specified column.
DuckDB.duckdb_open
— Methodduckdb_open(path, out_database)
Creates a new database or opens an existing database file stored at the given path. If no path is given a new in-memory database is created instead.
path
: Path to the database file on disk, ornullptr
or:memory:
to open an in-memory database.out_database
: The result database object.- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DuckDB.duckdb_open_ext
— MethodExtended version of duckdb_open. Creates a new database or opens an existing database file stored at the given path.
* path: Path to the database file on disk, or `nullptr` or `:memory:` to open an in-memory database.
* out_database: The result database object.
* config: (Optional) configuration used to start up the database system.
* out_error: If set and the function returns DuckDBError, this will contain the reason why the start-up failed.
Note that the error must be freed using `duckdb_free`.
* returns: `DuckDBSuccess` on success or `DuckDBError` on failure.
DuckDB.duckdb_param_type
— MethodReturns the parameter type for the parameter at the given index. Returns DUCKDB_TYPE_INVALID
if the parameter index is out of range or the statement was not successfully prepared.
- prepared_statement: The prepared statement.
- param_idx: The parameter index.
- returns: The parameter type
DUCKDBAPI duckdbtype duckdbparamtype(duckdbpreparedstatement preparedstatement, idxt param_idx);
DuckDB.duckdb_pending_error
— MethodReturns the error message contained within the pending result.
The result of this function must not be freed. It will be cleaned up when duckdb_destroy_pending
is called.
- result: The pending result to fetch the error from.
- returns: The error of the pending result.
DuckDB.duckdb_pending_execute_check_state
— MethodChecks the state of the execution, returning it. The pending result represents an intermediate structure for a query that is not yet fully executed.
If this returns DUCKDBPENDINGRESULTREADY, the duckdbexecutepending function can be called to obtain the result. If this returns DUCKDBPENDINGRESULTNOTREADY, the duckdbpendingexecutecheckstate function should be called again. If this returns DUCKDBPENDING_ERROR, an error occurred during execution.
The error message can be obtained by calling duckdbpendingerror on the pending_result.
- pending_result: The pending result to check the state of.
- returns: The state of the pending result.
DuckDB.duckdb_pending_execute_task
— MethodExecutes a single task within the query, returning whether or not the query is ready.
If this returns DUCKDBPENDINGRESULTREADY, the duckdbexecutepending function can be called to obtain the result. If this returns DUCKDBPENDINGRESULTNOTREADY, the duckdbpendingexecutetask function should be called again. If this returns DUCKDBPENDINGERROR, an error occurred during execution.
The error message can be obtained by calling duckdbpendingerror on the pending_result.
- pending_result: The pending result to execute a task within.
- returns: The state of the pending result after the execution.
DuckDB.duckdb_pending_execution_is_finished
— MethodReturns whether a duckdbpendingstate is finished executing. For example if pending_state
is DUCKDBPENDINGRESULT_READY, this function will return true.
- pending_state: The pending state on which to decide whether to finish execution.
- returns: Boolean indicating pending execution should be considered finished.
DuckDB.duckdb_pending_prepared
— MethodExecutes the prepared statement with the given bound parameters, and returns a pending result. The pending result represents an intermediate structure for a query that is not yet fully executed. The pending result can be used to incrementally execute a query, returning control to the client between tasks.
Note that after calling duckdb_pending_prepared
, the pending result should always be destroyed using duckdb_destroy_pending
, even if this function returns DuckDBError.
- prepared_statement: The prepared statement to execute.
- out_result: The pending query result.
- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DuckDB.duckdb_pending_prepared_streaming
— MethodExecutes the prepared statement with the given bound parameters, and returns a pending result. This pending result will create a streaming duckdb_result when executed. The pending result represents an intermediate structure for a query that is not yet fully executed.
Note that after calling duckdb_pending_prepared_streaming
, the pending result should always be destroyed using duckdb_destroy_pending
, even if this function returns DuckDBError.
- prepared_statement: The prepared statement to execute.
- out_result: The pending query result.
- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DuckDB.duckdb_prepare
— MethodCreate a prepared statement object from a query. Note that after calling duckdb_prepare
, the prepared statement should always be destroyed using duckdb_destroy_prepare
, even if the prepare fails. If the prepare fails, duckdb_prepare_error
can be called to obtain the reason why the prepare failed.
- connection: The connection object
- query: The SQL query to prepare
- outpreparedstatement: The resulting prepared statement object
- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DUCKDBAPI duckdbstate duckdbprepare(duckdbconnection connection, const char *query, duckdbpreparedstatement *outpreparedstatement);
DuckDB.duckdb_prepare_error
— MethodReturns the error message associated with the given prepared statement. If the prepared statement has no error message, this returns nullptr
instead. The error message should not be freed. It will be de-allocated when duckdb_destroy_prepare
is called.
- prepared_statement: The prepared statement to obtain the error from.
- returns: The error message, or
nullptr
if there is none.
DUCKDBAPI const char *duckdbprepareerror(duckdbpreparedstatement preparedstatement);
DuckDB.duckdb_query
— Methodduckdb_query(connection,query,out_result)
Executes a SQL query within a connection and stores the full (materialized) result in the outresult pointer. If the query fails to execute, DuckDBError is returned and the error message can be retrieved by calling `duckdbresulterror. Note that after running
duckdbquery,
duckdbdestroyresult` must be called on the result object even if the query fails, otherwise the error stored within the result will not be freed correctly.
connection
: The connection to perform the query in.query
: The SQL query to run.out_result
: The query result.- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DuckDB.duckdb_register_table_function
— MethodRegister the table function object within the given connection.
The function requires at least a name, a bind function, an init function and a main function.
If the function is incomplete or a function with this name already exists DuckDBError is returned.
- con: The connection to register it in.
- function: The function pointer
- returns: Whether or not the registration was successful.
DuckDB.duckdb_replacement_scan_add_parameter
— MethodAdds a parameter to the replacement scan function.
- info: The info object
- parameter: The parameter to add. The function will call
duckdb_destroy_value
on the parameter.
DuckDB.duckdb_replacement_scan_set_error
— MethodReport that an error has occurred while executing the replacement scan.
- info: The info object
- error: The error message
DuckDB.duckdb_replacement_scan_set_function_name
— MethodSets the replacement function name to use. If this function is called in the replacement callback, the replacement scan is performed. If it is not called, the replacement callback is not performed.
- info: The info object
- function_name: The function name to substitute.
DuckDB.duckdb_result_chunk_count
— MethodReturns the number of data chunks present in the result.
- result: The result object
- returns: The resulting data chunk. Returns
NULL
if the chunk index is out of bounds.
DuckDB.duckdb_result_error
— Methodduckdb_result_error(result)
Returns the error message contained within the result. The error is only set if duckdb_query
returns DuckDBError
. The result of this function must not be freed. It will be cleaned up when duckdb_destroy_result
is called.
result
: The result object to fetch the nullmask from.- returns: The error of the result.
DuckDB.duckdb_result_get_chunk
— MethodFetches a data chunk from the duckdb_result. This function should be called repeatedly until the result is exhausted.
This function supersedes all duckdb_value
functions, as well as the duckdb_column_data
and duckdb_nullmask_data
functions. It results in significantly better performance, and should be preferred in newer code-bases.
If this function is used, none of the other result functions can be used and vice versa (i.e. this function cannot be mixed with the legacy result functions).
Use duckdb_result_chunk_count
to figure out how many chunks there are in the result.
- result: The result object to fetch the data chunk from.
- chunk_index: The chunk index to fetch from.
- returns: The resulting data chunk. Returns
NULL
if the chunk index is out of bounds.
DuckDB.duckdb_result_is_streaming
— MethodChecks if the type of the internal result is StreamQueryResult.
- result: The result object to check.
- returns: Whether or not the result object is of the type StreamQueryResult
DuckDB.duckdb_row_count
— Methodduckdb_row_count(result)
Returns the number of rows present in a the result object.
result
: The result object.- returns: The number of rows present in the result object.
DuckDB.duckdb_rows_changed
— Methodduckdb_rows_changed(result)
Returns the number of rows changed by the query stored in the result. This is relevant only for INSERT/UPDATE/DELETE queries. For other queries the rows_changed will be 0.
result
: The result object.- returns: The number of rows changed.
DuckDB.duckdb_set_config
— Methodduckdb_set_config(config,name,option)
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
. In the source code, configuration options are defined in config.cpp
. This can fail if either the name is invalid, or if the value provided for the option is invalid.
duckdb_config
: The configuration object to set the option on.name
: The name of the configuration flag to set.option
: The value to set the configuration flag to.- returns:
DuckDBSuccess
on success orDuckDBError
on failure.
DuckDB.duckdb_stream_fetch_chunk
— MethodFetches a data chunk from the (streaming) duckdb_result. This function should be called repeatedly until the result is exhausted.
The result must be destroyed with duckdb_destroy_data_chunk
.
This function can only be used on duckdbresults created with 'duckdbpendingpreparedstreaming'
If this function is used, none of the other result functions can be used and vice versa (i.e. this function cannot be mixed with the legacy result functions or the materialized result functions).
It is not known beforehand how many chunks will be returned by this result.
- result: The result object to fetch the data chunk from.
- returns: The resulting data chunk. Returns
NULL
if the result has an error.
DuckDB.duckdb_struct_type_child_count
— MethodReturns the number of children of a struct type.
- type: The logical type object
- returns: The number of children of a struct type.
DuckDB.duckdb_struct_type_child_name
— MethodRetrieves the name of the struct child.
The result must be freed with duckdb_free
- type: The logical type object
- index: The child index
- returns: The name of the struct type. Must be freed with
duckdb_free
.
DuckDB.duckdb_struct_type_child_type
— MethodRetrieves the child type of the given struct type at the specified index.
The result must be freed with duckdb_destroy_logical_type
- type: The logical type object
- index: The child index
- returns: The child type of the struct type. Must be destroyed with
duckdb_destroy_logical_type
.
DuckDB.duckdb_struct_vector_get_child
— MethodRetrieves the child vector of a struct vector.
The resulting vector is valid as long as the parent vector is valid.
- vector: The vector
- index: The child index
- returns: The child vector
DuckDB.duckdb_table_function_add_parameter
— MethodAdds a parameter to the table function.
- table_function: The table function
- type: The type of the parameter to add.
DuckDB.duckdb_table_function_set_bind
— MethodSets the bind function of the table function
- table_function: The table function
- bind: The bind function
DuckDB.duckdb_table_function_set_extra_info
— MethodAssigns extra information to the table function that can be fetched during binding, etc.
- table_function: The table function
- extra_info: The extra information
- destroy: The callback that will be called to destroy the bind data (if any)
DuckDB.duckdb_table_function_set_function
— MethodSets the main function of the table function
- table_function: The table function
- function: The function
DuckDB.duckdb_table_function_set_init
— MethodSets the init function of the table function
- table_function: The table function
- init: The init function
DuckDB.duckdb_table_function_set_local_init
— MethodSets the thread-local init function of the table function
- table_function: The table function
- init: The init function
DuckDB.duckdb_table_function_set_name
— MethodSets the name of the given table function.
- table_function: The table function
- name: The name of the table function
DuckDB.duckdb_table_function_supports_projection_pushdown
— MethodSets whether or not the given table function supports projection pushdown.
If this is set to true, the system will provide a list of all required columns in the init
stage through the duckdb_init_get_column_count
and duckdb_init_get_column_index
functions. If this is set to false (the default), the system will expect all columns to be projected.
- table_function: The table function
- pushdown: True if the table function supports projection pushdown, false otherwise.
DuckDB.duckdb_task_state_is_finished
— MethodCheck if the provided duckdbtaskstate has finished execution
- state: The task state to inspect
- returns: Whether or not duckdbfinishexecution has been called on the task state
DuckDB.duckdb_union_type_member_count
— MethodReturns the number of members of a union type.
- type: The logical type object
- returns: The number of members of a union type.
DuckDB.duckdb_union_type_member_name
— MethodRetrieves the name of the union member.
The result must be freed with duckdb_free
- type: The logical type object
- index: The member index
- returns: The name of the union member. Must be freed with
duckdb_free
.
DuckDB.duckdb_union_type_member_type
— MethodRetrieves the member type of the given union type at the specified index.
The result must be freed with duckdb_destroy_logical_type
- type: The logical type object
- index: The member index
- returns: The member type of the union type. Must be destroyed with
duckdb_destroy_logical_type
.
DuckDB.duckdb_union_vector_get_member
— MethodRetrieves the member vector of a union vector.
The resulting vector is valid as long as the parent vector is valid.
- vector: The vector
- index: The member index
- returns: The member vector
DuckDB.duckdb_value_boolean
— Methodduckdb_value_boolean(result,col,row)
- returns: The boolean value at the specified location, or false if the value cannot be converted.
DuckDB.duckdb_value_date
— Methodduckdbvaluedate(result,col,row)
- returns: The duckdb_date value at the specified location, or 0 if the value cannot be converted.
DUCKDBAPI duckdbdate duckdbvaluedate(duckdbresult *result, idxt col, idx_t row);
DuckDB.duckdb_value_double
— Methodduckdb_value_double(result,col,row)
- returns: The double value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_float
— Methodduckdb_value_float(result,col,row)
- returns: The float value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_hugeint
— Methodduckdb_value_hugeint(result,col,row)
- returns: The duckdb_hugeint value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_int16
— Methodduckdb_value_int16(result,col,row)
- returns: The int16_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_int32
— Methodduckdb_value_int32(result,col,row)
- returns: The int32_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_int64
— Methodduckdb_value_int64(result,col,row)
- returns: The int64_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_int8
— Methodduckdb_value_int8(result,col,row)
- returns: The int8_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_interval
— Methodduckdbvalueinterval(result,col,row)
- returns: The duckdb_interval value at the specified location, or 0 if the value cannot be converted.
DUCKDBAPI duckdbinterval duckdbvalueinterval(duckdbresult *result, idxt col, idx_t row);
DuckDB.duckdb_value_is_null
— Methodduckdbvalueis_null(result,col,row)
- returns: Returns true if the value at the specified index is NULL, and false otherwise.
DUCKDBAPI bool duckdbvalueisnull(duckdbresult *result, idxt col, idx_t row);
DuckDB.duckdb_value_time
— Methodduckdbvaluetime(result,col,row)
- returns: The duckdb_time value at the specified location, or 0 if the value cannot be converted.
DUCKDBAPI duckdbtime duckdbvaluetime(duckdbresult *result, idxt col, idx_t row);
DuckDB.duckdb_value_timestamp
— Methodduckdbvaluetimestamp(result,col,row)
- returns: The duckdb_timestamp value at the specified location, or 0 if the value cannot be converted.
DUCKDBAPI duckdbtimestamp duckdbvaluetimestamp(duckdbresult *result, idxt col, idx_t row);
DuckDB.duckdb_value_uhugeint
— Methodduckdb_value_uhugeint(result,col,row)
- returns: The duckdb_uhugeint value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_uint16
— Methodduckdb_value_uint16(result,col,row)
- returns: The uint16_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_uint32
— Methodduckdb_value_uint32(result,col,row)
- returns: The uint32_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_uint64
— Methodduckdb_value_uint64(result,col,row)
- returns: The uint64_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_uint8
— Methodduckdb_value_uint8(result,col,row)
- returns: The uint8_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_varchar
— Methodduckdbvaluevarchar(result,col,row)
- returns: The char* value at the specified location, or nullptr if the value cannot be converted.
The result must be freed with duckdb_free
. DUCKDBAPI char *duckdbvaluevarchar(duckdbresult *result, idxt col, idxt row);
DuckDB.duckdb_value_varchar_internal
— Methodduckdbvaluevarchar_internal(result,col,row)
- returns: The char* value at the specified location. ONLY works on VARCHAR columns and does not auto-cast.
If the column is NOT a VARCHAR column this function will return NULL. The result must NOT be freed. DUCKDBAPI char *duckdbvaluevarcharinternal(duckdbresult *result, idxt col, idx_t row);
DuckDB.duckdb_vector_assign_string_element
— MethodAssigns a string element in the vector at the specified location.
- vector: The vector to alter
- index: The row position in the vector to assign the string to
- str: The null-terminated string
DuckDB.duckdb_vector_assign_string_element_len
— MethodAssigns a string element in the vector at the specified location.
- vector: The vector to alter
- index: The row position in the vector to assign the string to
- str: The null-terminated string
- str_len: The string length
DuckDB.duckdb_vector_ensure_validity_writable
— MethodEnsures the validity mask is writable by allocating it.
After this function is called, duckdb_vector_get_validity
will ALWAYS return non-NULL. This allows null values to be written to the vector, regardless of whether a validity mask was present before.
- vector: The vector to alter
DuckDB.duckdb_vector_get_column_type
— MethodRetrieves the column type of the specified vector.
The result must be destroyed with duckdb_destroy_logical_type
.
- vector: The vector get the data from
- returns: The type of the vector
DuckDB.duckdb_vector_get_data
— MethodRetrieves the data pointer of the vector.
The data pointer can be used to read or write values from the vector. How to read or write values depends on the type of the vector.
- vector: The vector to get the data from
- returns: The data pointer
DuckDB.duckdb_vector_get_validity
— MethodRetrieves the validity mask pointer of the specified vector.
If all values are valid, this function MIGHT return NULL!
The validity mask is a bitset that signifies null-ness within the data chunk. It is a series of uint64t values, where each uint64t value contains validity for 64 tuples. The bit is set to 1 if the value is valid (i.e. not NULL) or 0 if the value is invalid (i.e. NULL).
Validity of a specific value can be obtained like this:
idxt entryidx = rowidx / 64; idxt idxinentry = rowidx % 64; bool isvalid = validitymask[entryidx] & (1 << idxinentry);
Alternatively, the (slower) duckdbvalidityrowisvalid function can be used.
- vector: The vector to get the data from
- returns: The pointer to the validity mask, or NULL if no validity mask is present
DuckDB.duckdb_vector_size
— MethodThe internal vector size used by DuckDB. This is the amount of tuples that will fit into a data chunk created by duckdb_create_data_chunk
.
- returns: The vector size.
DuckDB.load!
— FunctionDuckDB.load!(con, input_df, table)
Load an input DataFrame input_df
into a new DuckDB table that will be named table
.
DuckDB.query
— MethodExecutes a SQL query within a connection and returns the full (materialized) result.
The query function is able to run queries with multiple statements, unlike DBInterface.execute
(@ref) which is only able to prepare a single statement.
DuckDB.rollback
— FunctionDuckDB.rollback(db)
rollback transaction