Copyright © 2022 Maas-Maarten Zeeman
Authors: Maas-Maarten Zeeman (mmzeeman@xs4all.nl).
append_response() = ok | {error, term()}
appender() = reference()
bind_response() = ok | {error, term()}
column() = #{data := [data()], type := type_name()}
connection() = reference()
data() = boolean() | int8() | int16() | int32() | int64() | uint8() | uint16() | uint32() | uint64() | float() | hugeint() | calendar:date() | time() | datetime() | binary() | [data()] | #{binary() => data()} | {map, [data()], [data()]}
data_chunk() = reference()
database() = reference()
datetime() = {calendar:date(), time()}
hugeint() = #hugeint{upper = educkdb:int64(), lower = educkdb:uint64()}
idx() = 0..18446744073709551615
int16() = -32767..32767
int32() = -2147483647..2147483647
int64() = -9223372036854775807..9223372036854775807
int8() = -127..127
named_column() = #{name := binary(), data := [data()], type := type_name()}
prepared_statement() = reference()
result() = reference()
second() = float()
In the range 0.0..60.0
sql() = iodata()
time() = {calendar:hour(), calendar:minute(), second()}
type_name() = boolean | tinyint | smallint | integer | bigint | utinyint | usmallint | uinteger | ubigint | float | double | hugeint | timestamp | date | time | interval | varchar | blob | decimal | timestamp_s | timestamp_ms | timestamp_ns | enum | list | struct | map | uuid | json
Note: decimal, timestamp_s, timestamp_ms, timestamp_ns and interval's are not supported yet.
uint16() = 0..65535
uint32() = 0..4294967295
uint64() = 0..18446744073709551615
uint8() = 0..255
open/1 | Open, or create a duckdb database with default options. |
open/2 | Open, or create a duckdb file. |
connect/1 | Connect to the database. |
disconnect/1 | Disconnect from the database. |
close/1 | Close the database. |
config_flag_info/0 | Return a map with config flags, and explanations. |
query/2 | Query the database. |
query_cmd/2 | Query the database. |
prepare/2 | Compile, and prepare a statement for later execution. |
execute_prepared/1 | |
execute_prepared_cmd/1 | |
bind_boolean/3 | Bind a boolean to the prepared statement at the specified index. |
bind_int8/3 | Bind an int8 to the prepared statement at the specified index. |
bind_int16/3 | Bind an int16 to the prepared statement at the specified index. |
bind_int32/3 | Bind an int32 to the prepared statement at the specified index. |
bind_int64/3 | Bind an int64 to the prepared statement at the specified index. |
bind_uint8/3 | Bind an uint8 to the prepared statement at the specified index. |
bind_uint16/3 | Bind an uint8 to the prepared statement at the specified index. |
bind_uint32/3 | Bind an uint32 to the prepared statement at the specified index. |
bind_uint64/3 | Bind an uint64 to the prepared statement at the specified index. |
bind_float/3 | Bind an float to the prepared statement at the specified index. |
bind_double/3 | Bind an uint64 to the prepared statement at the specified index. |
bind_date/3 | Bind a date to the prepared statement at the specified index. |
bind_time/3 | Bind a time to the prepared statement at the specified index. |
bind_timestamp/3 | Bind a timestamp to the prepared statement at the specified index. |
bind_varchar/3 | Bind a iolist as varchar to the prepared statement at the specified index. |
bind_null/2 | Bind a null value to the prepared statement at the specified index. |
get_chunks/1 | Get all data chunks from a query result. |
get_chunk/2 | Get a data chunk from a query result. |
chunk_count/1 | Get the number of data chunks in a query result. |
column_names/1 | Get the column names from the query result. |
extract_chunk/1 | Extract the data from a data chunk. |
get_chunk_column_count/1 | |
get_chunk_size/1 | |
appender_create/3 | |
append_boolean/2 | |
append_int8/2 | |
append_int16/2 | |
append_int32/2 | |
append_int64/2 | |
append_uint8/2 | |
append_uint16/2 | |
append_uint32/2 | |
append_uint64/2 | |
append_float/2 | |
append_double/2 | |
append_time/2 | |
append_date/2 | |
append_timestamp/2 | |
append_varchar/2 | |
append_null/1 | |
appender_flush/1 | |
appender_end_row/1 | |
extract_result/1 | Extract a query result of the first data chunk. |
squery/2 | Do a simple sql query without parameters, and retrieve the result from the first data chunk. |
execute/1 | Execute a prepared statement, and retrieve the first result from the first data chunk. |
hugeint_to_integer/1 | Convert a duckdb hugeint record to erlang integer. |
integer_to_hugeint/1 | Convert an erlang integer to a DuckDB hugeint. |
uuid_binary_to_uuid_string/1 | Convert a binary represented UUID to a printable hex representation. |
uuid_string_to_uuid_binary/1 | Convert a printable UUID to a binary representation. |
Open, or create a duckdb database with default options.
open(Filename, Options) -> Result
Open, or create a duckdb file
Connect to the database. In the background a thread is started which is used by long running commands. Note: It is adviced to use the connection in a single process.
Disconnect from the database. Stops the thread. The calling pid will receive: {disconnect, Ref, ok | {error, _}}.
Close the database. All open connections will become unusable.
config_flag_info() -> map()
Return a map with config flags, and explanations. The options can vary depending on the underlying DuckDB version used. For more information about DuckDB configuration options, see: DuckDB Configuration.
query(Connection, Sql) -> Result
Query the database. The answer the answer is returned immediately. Special care has been taken to prevent blocking the scheduler. A reference to a result data structure will be returned.
query_cmd(Conn::connection(), Sql::sql()) -> {ok, reference()} | {error, term()}
Query the database. The answer is send back as a result to the calling process.
prepare(Conn::connection(), Sql::sql()) -> {ok, prepared_statement()} | {error, term()}
Compile, and prepare a statement for later execution.
execute_prepared(PreparedStatement) -> Result
execute_prepared_cmd(PreparedStatement) -> Result
bind_boolean(PreparedStatement, Index, Boolean) -> BindResponse
Bind a boolean to the prepared statement at the specified index.
bind_int8(PreparedStatement, Index, Int8) -> BindResponse
Bind an int8 to the prepared statement at the specified index.
bind_int16(PreparedStatement, Index, Int16) -> BindResponse
Bind an int16 to the prepared statement at the specified index.
bind_int32(PreparedStatement, Index, Int32) -> BindResponse
Bind an int32 to the prepared statement at the specified index.
bind_int64(PreparedStatement, Index, Int64) -> BindResponse
Bind an int64 to the prepared statement at the specified index.
bind_uint8(PreparedStatement, Index, UInt8) -> BindResponse
Bind an uint8 to the prepared statement at the specified index.
bind_uint16(PreparedStatement, Index, UInt16) -> BindResponse
Bind an uint8 to the prepared statement at the specified index.
bind_uint32(PreparedStatement, Index, UInt32) -> BindResponse
Bind an uint32 to the prepared statement at the specified index.
bind_uint64(PreparedStatement, Index, UInt64) -> BindResponse
Bind an uint64 to the prepared statement at the specified index.
bind_float(PreparedStatement, Index, Float) -> BindResponse
Bind an float to the prepared statement at the specified index. Note: Erlang's float() datatype is actually a DuckDB double. When binding an Erlang float variable you will lose precision.
bind_double(PreparedStatement, Index, Double) -> BindResponse
Bind an uint64 to the prepared statement at the specified index. Note: Erlang's float datatype is a DuckDB double. Using this function allows you to keep the precision.
bind_date(PreparedStatement, Index, Date) -> BindResponse
Bind a date to the prepared statement at the specified index. The date can be either given as a calendar:date() tuple, or an integer with the number of days since the first of January in the year 0.
bind_time(PreparedStatement, Index, Time) -> BindResponse
Bind a time to the prepared statement at the specified index. The time can be either given as an {hour, minute, second} tuple (similar to calendar:time()), or as an integer with the number of microseconds since midnight.
bind_timestamp(PreparedStatement, Index, TimeStamp) -> BindResponse
Bind a timestamp to the prepared statement at the specified index. The timestamp can be either a datetime tuple, or an integer with the microseconds since 1-Jan in the year 0.
bind_varchar(PreparedStatement, Index, IOData) -> BindResponse
Bind a iolist as varchar to the prepared statement at the specified index. Note: This function is meant to bind null terminated strings in the database. Not arbitrary binary data.
bind_null(PreparedStatement, Index) -> BindResponse
Bind a null value to the prepared statement at the specified index.
Get all data chunks from a query result.
get_chunk(QueryResult, Idx) -> DataChunk
Get a data chunk from a query result.
Get the number of data chunks in a query result.
Get the column names from the query result.
Extract the data from a data chunk. Chunks contain multiple columns and rows. All data in the chunks is extracted.
get_chunk_column_count(Chunk::data_chunk()) -> uint64()
get_chunk_size(Chunk::data_chunk()) -> uint64()
appender_create(Connection::connection(), Schema::string(), Table::string()) -> {ok, appender()} | {error, term()}
append_boolean(Appender::appender(), X2::boolean()) -> append_response()
append_int8(Appender::appender(), Integer::int8()) -> append_response()
append_int16(Appender::appender(), Integer::int16()) -> append_response()
append_int32(Appender::appender(), Integer::int32()) -> append_response()
append_int64(Appender::appender(), Integer::integer()) -> append_response()
append_uint8(Appender::appender(), Integer::uint8()) -> append_response()
append_uint16(Appender::appender(), Integer::uint16()) -> append_response()
append_uint32(Appender::appender(), Integer::uint32()) -> append_response()
append_uint64(Appender::appender(), Integer::uint64()) -> append_response()
append_float(Appender::appender(), Integer::float()) -> append_response()
append_double(Appender::appender(), Integer::float()) -> append_response()
append_time(Appender, Micros) -> any()
append_date(Appender, Date) -> any()
append_timestamp(Appender, Micros) -> any()
append_varchar(Appender::appender(), IOData::iodata()) -> append_response()
append_null(Appender::appender()) -> append_response()
appender_flush(Appender::appender()) -> append_response()
appender_end_row(Appender::appender()) -> append_response()
Extract a query result of the first data chunk.
squery(Connection, Sql) -> Result
Do a simple sql query without parameters, and retrieve the result from the first data chunk.
execute(PreparedStatement) -> Result
Execute a prepared statement, and retrieve the first result from the first data chunk.
Convert a duckdb hugeint record to erlang integer.
Convert an erlang integer to a DuckDB hugeint.
For more information on DuckDB numeric types: See DuckDB Numeric Data Types.uuid_binary_to_uuid_string(Bin) -> any()
Convert a binary represented UUID to a printable hex representation.
uuid_string_to_uuid_binary(U) -> any()
Convert a printable UUID to a binary representation.
Generated by EDoc