Copyright © 2022-2024 Maas-Maarten Zeeman
Authors: Maas-Maarten Zeeman (mmzeeman@xs4all.nl
).
append_response() = ok | {error, term()}
appender() = reference()
bind_response() = ok | {error, term()}
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()}
struct, making up a 128 bit signed integer.
idx() = uint64()
DuckDB index type
int16() = -32767..32767
DuckDB shortint
int32() = -2147483647..2147483647
DuckDB integer
int64() = -9223372036854775807..9223372036854775807
DuckDB bigint
int8() = -127..127
DuckDB tinyint
named_column() = #{name := binary(), data := [data()], type := type_name()}
prepared_statement() = reference()
result() = reference()
second() = calendar:time() | float()
In the range 0.0..60.0
sql() = iodata()
statement_type() = invalid | select | insert | update | explain | delete | prepare | create | execute | alter | transaction | copy | analyze | variable_set | create_func | drop | export | pragma | vacuum | call | set | load | relation | extension | logical_plan | attach | detach | multi | unknown
time() = {calendar:hour(), calendar:minute(), second()}
type_name() = boolean | tinyint | smallint | integer | bigint | utinyint | usmallint | uinteger | ubigint | float | double | hugeint | uhugeint | timestamp | date | time | interval | varchar | blob | decimal | timestamp_s | timestamp_ms | timestamp_ns | enum | interval | list | struct | map | uuid | json
Note: decimal, timestamp_s, timestamp_ms, timestamp_ns and interval's are not supported yet.
uhugeint() = #uhugeint{upper = educkdb:uint64(), lower = educkdb:uint64()}
struct, making up a 128 bit unsigned integer.
uint16() = 0..65535
DuckDB ushortint
uint32() = 0..4294967295
DuckDB uinteger
uint64() = 0..18446744073709551615
DuckDB ubigint
uint8() = 0..255
DuckDB duckdb utinyint
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. |
prepare/2 | Compile, and prepare a statement for later execution. |
statement_type/1 | Return the statement type of a prepared statement. |
execute_prepared/1 | Execute a prepared statement. |
parameter_name/2 | Return the parameter name of the prepared statement at the specified index. |
parameter_type/2 | Return the parameter type of the prepared statement at the specified index. |
parameter_count/1 | Return the number of parameters in a prepared statement. |
parameter_index/2 | |
clear_bindings/1 | Return the parameter type of the prepared statement at the specified index. |
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. |
fetch_chunk/1 | Fetches a data chunk from a result. |
column_names/1 | Get the column names from the query result. |
chunk_column_count/1 | Return the number of columns in the data chunk. |
chunk_column_types/1 | Get the column types of the chunk [todo] spec.. |
chunk_columns/1 | Get the columns data of the chunk [todo] spec. |
chunk_size/1 | Return the number of tuples in th data chunk. |
appender_create/3 | Create an appender. |
append_boolean/2 | Append a boolean value to the current location in the row. |
append_int8/2 | Append a tinyint to the current location in the row. |
append_int16/2 | Append a smallint to the current location in the row. |
append_int32/2 | Append an integer (32 bit) to the current location in the row. |
append_int64/2 | Append a bigint to the current location in the row. |
append_uint8/2 | Append a utinyint to the current location in the row. |
append_uint16/2 | Append a usmallint to the current location in the row. |
append_uint32/2 | Append an unsigned integer (32 bit) to the current location in the row. |
append_uint64/2 | Append a ubigint to the current location in the row. |
append_float/2 | Append a float to the current location in the row. |
append_double/2 | Append a double to the current location in the row. |
append_time/2 | Append a time to the current location in the row. |
append_date/2 | Append a data to the current location in the row. |
append_timestamp/2 | Append a timestamp to the current location in the row. |
append_varchar/2 | Append a varchar to the current location in the row. |
append_null/1 | Append a null value to the current location in the row. |
appender_end_row/1 | Finalize the current row, and start a new one. |
appender_flush/1 | Flush the appender to the table, forcing the cache of the appender to be cleared and the data to be appended to the base table. |
result_extract/1 | |
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 an erlang integer. |
integer_to_hugeint/1 | Convert an erlang integer to a DuckDB hugeint. |
uhugeint_to_integer/1 | Convert a duckdb uhugeint record to an erlang integer. |
integer_to_uhugeint/1 | |
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
Filename = string()
Options = map()
Result = {ok, database()} | {error, term()}
Open, or create a duckdb file
Connect to the database. Note: It is adviced to use the connection in a single process.
Disconnect from the database.
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
Connection = connection()
Sql = sql()
Result = {ok, result()} | {error, term()}
Query the database. The answer the answer is returned immediately.
prepare(Conn::connection(), Sql::sql()) -> {ok, prepared_statement()} | {error, term()}
Compile, and prepare a statement for later execution.
statement_type(PreparedStatement) -> Result
PreparedStatement = prepared_statement()
Result = statement_type()
Return the statement type of a prepared statement.
execute_prepared(PreparedStatement) -> Result
PreparedStatement = prepared_statement()
Result = {ok, result()} | {error, term()}
Execute a prepared statement. The answer is returned.
parameter_name(PreparedStatement, Index) -> ParameterName
PreparedStatement = prepared_statement()
Index = idx()
ParameterName = binary()
Return the parameter name of the prepared statement at the specified index.
parameter_type(PreparedStatement, Index) -> ParameterType
PreparedStatement = prepared_statement()
Index = idx()
ParameterType = type_name()
Return the parameter type of the prepared statement at the specified index.
Return the number of parameters in a prepared statement.
parameter_index(PreparedStatement, Name) -> non_neg_integer()
PreparedStatement = prepared_statement()
Name = atom() | binary()
Return the parameter type of the prepared statement at the specified index.
bind_boolean(PreparedStatement, Index, Boolean) -> BindResponse
PreparedStatement = prepared_statement()
Index = idx()
Boolean = boolean()
BindResponse = bind_response()
Bind a boolean to the prepared statement at the specified index.
bind_int8(PreparedStatement, Index, Int8) -> BindResponse
PreparedStatement = prepared_statement()
Index = idx()
Int8 = int8()
BindResponse = bind_response()
Bind an int8 to the prepared statement at the specified index.
bind_int16(PreparedStatement, Index, Int16) -> BindResponse
PreparedStatement = prepared_statement()
Index = idx()
Int16 = int16()
BindResponse = bind_response()
Bind an int16 to the prepared statement at the specified index.
bind_int32(PreparedStatement, Index, Int32) -> BindResponse
PreparedStatement = prepared_statement()
Index = idx()
Int32 = int32()
BindResponse = bind_response()
Bind an int32 to the prepared statement at the specified index.
bind_int64(PreparedStatement, Index, Int64) -> BindResponse
PreparedStatement = prepared_statement()
Index = idx()
Int64 = int64()
BindResponse = bind_response()
Bind an int64 to the prepared statement at the specified index.
bind_uint8(PreparedStatement, Index, UInt8) -> BindResponse
PreparedStatement = prepared_statement()
Index = idx()
UInt8 = uint8()
BindResponse = bind_response()
Bind an uint8 to the prepared statement at the specified index.
bind_uint16(PreparedStatement, Index, UInt16) -> BindResponse
PreparedStatement = prepared_statement()
Index = idx()
UInt16 = uint16()
BindResponse = bind_response()
Bind an uint8 to the prepared statement at the specified index.
bind_uint32(PreparedStatement, Index, UInt32) -> BindResponse
PreparedStatement = prepared_statement()
Index = idx()
UInt32 = uint32()
BindResponse = bind_response()
Bind an uint32 to the prepared statement at the specified index.
bind_uint64(PreparedStatement, Index, UInt64) -> BindResponse
PreparedStatement = prepared_statement()
Index = idx()
UInt64 = uint64()
BindResponse = bind_response()
Bind an uint64 to the prepared statement at the specified index.
bind_float(PreparedStatement, Index, Float) -> BindResponse
PreparedStatement = prepared_statement()
Index = idx()
Float = float()
BindResponse = bind_response()
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
PreparedStatement = prepared_statement()
Index = idx()
Double = float()
BindResponse = bind_response()
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
PreparedStatement = prepared_statement()
Index = idx()
Date = calendar:date() | integer()
BindResponse = bind_response()
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
PreparedStatement = prepared_statement()
Index = idx()
Time = calendar:time() | time() | non_neg_integer()
BindResponse = bind_response()
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
PreparedStatement = prepared_statement()
Index = idx()
TimeStamp = calendar:datetime() | datetime() | integer()
BindResponse = bind_response()
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
PreparedStatement = prepared_statement()
Index = idx()
IOData = iodata()
BindResponse = bind_response()
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
PreparedStatement = prepared_statement()
Index = idx()
BindResponse = bind_response()
Bind a null value to the prepared statement at the specified index.
Get all data chunks from a query result.
Fetches a data chunk from a result. The function should be called repeatedly until the result is exhausted.
Get the column names from the query result.
Return the number of columns in the data chunk.
chunk_column_types(Chunk) -> any()
Get the column types of the chunk [todo] spec..
chunk_columns(Chunk) -> any()
Get the columns data of the chunk [todo] spec
Return the number of tuples in th data chunk.
appender_create(Connection, Schema, Table) -> Result
Connection = connection()
Schema = undefined | binary()
Table = binary
Result = {ok, appender()} | {error, term()}
Create an appender. Appenders allow for high speed bulk insertions into the database. See DuckDB Appender for more information.
append_boolean(Appender, Boolean) -> AppendResponse
Appender = appender()
Boolean = boolean()
AppendResponse = append_response()
Append a boolean value to the current location in the row.
append_int8(Appender, TinyInt) -> AppendResponse
Appender = appender()
TinyInt = int8()
AppendResponse = append_response()
Append a tinyint to the current location in the row.
append_int16(Appender, SmallInt) -> AppendResponse
Appender = appender()
SmallInt = int16()
AppendResponse = append_response()
Append a smallint to the current location in the row.
append_int32(Appender, Integer) -> AppendResponse
Appender = appender()
Integer = int32()
AppendResponse = append_response()
Append an integer (32 bit) to the current location in the row.
append_int64(Appender, BigInt) -> AppendResponse
Appender = appender()
BigInt = int64()
AppendResponse = append_response()
Append a bigint to the current location in the row.
append_uint8(Appender, UTinyInt) -> AppendResponse
Appender = appender()
UTinyInt = uint8()
AppendResponse = append_response()
Append a utinyint to the current location in the row.
append_uint16(Appender, USmallInt) -> AppendResponse
Appender = appender()
USmallInt = uint16()
AppendResponse = append_response()
Append a usmallint to the current location in the row.
append_uint32(Appender, UInteger) -> AppendResponse
Appender = appender()
UInteger = uint32()
AppendResponse = append_response()
Append an unsigned integer (32 bit) to the current location in the row.
append_uint64(Appender, UBigInt) -> AppendResponse
Appender = appender()
UBigInt = uint64()
AppendResponse = append_response()
Append a ubigint to the current location in the row.
append_float(Appender, Float) -> AppendResponse
Appender = appender()
Float = float()
AppendResponse = append_response()
Append a float to the current location in the row. Note: duckdb floats are different than erlang floats. When you add an erlang float to a duckdb float column, you will loose precision.
append_double(Appender, Double) -> AppendResponse
Appender = appender()
Double = float()
AppendResponse = append_response()
Append a double to the current location in the row. Note: duckdb double's are the same as erlang floats.
append_time(Appender, Time) -> AppendResponse
Appender = appender()
Time = calendar:time() | time() | non_neg_integer()
AppendResponse = append_response()
Append a time to the current location in the row.
append_date(Appender, Date) -> AppendResponse
Appender = appender()
Date = calendar:date() | integer()
AppendResponse = append_response()
Append a data to the current location in the row.
append_timestamp(Appender, Timestamp) -> AppendResponse
Appender = appender()
Timestamp = calendar:datetime() | erlang:timestamp() | datetime() | integer()
AppendResponse = append_response()
Append a timestamp to the current location in the row.
append_varchar(Appender, IOData) -> AppendResponse
Appender = appender()
IOData = iodata()
AppendResponse = append_response()
Append a varchar to the current location in the row.
Append a null value to the current location in the row.
appender_end_row(Appender) -> AppendResponse
Appender = appender()
AppendResponse = append_response()
Finalize the current row, and start a new one.
Flush the appender to the table, forcing the cache of the appender to be cleared and the data to be appended to the base table.
result_extract(Result) -> any()
squery(Connection, Sql) -> Result
Connection = connection()
Sql = sql()
Result = {ok, [named_column()]} | {error, term()}
Do a simple sql query without parameters, and retrieve the result from the first data chunk.
execute(PreparedStatement) -> Result
PreparedStatement = prepared_statement()
Result = {ok, [named_column()]} | {error, term()}
Execute a prepared statement, and retrieve the first result from the first data chunk.
Convert a duckdb hugeint record to an erlang integer.
Convert an erlang integer to a DuckDB hugeint.
For more information on DuckDB numeric types: See DuckDB Numeric Data Types.Convert a duckdb uhugeint record to an erlang integer.
integer_to_uhugeint(NonNegInteger) -> UHugeint
NonNegInteger = non_neg_integer()
UHugeint = uhugeint()
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