duckdb 0.0.1
DuckDB client for D
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
d-duckdb
DuckDB client for D. This client is based on DuckDB's C API.
Usage
Iterate query result via foreach
import duckdb;
import std;
void main()
{
auto db = new Database(null); // null for in-memory database
auto conn = db.connect();
writeln(duckdbVersion);
conn.queryWithoutResult("CREATE TABLE integers (i INTEGER, j INTEGER);");
conn.queryWithoutResult("INSERT INTO integers VALUES (3, 4), (5, 6), (7, NULL);");
auto r = conn.query("SELECT * FROM integers;");
foreach (int a, Nullable!int b; r) // Specify argument types implicitly
writeln(a, ", ", b);
conn.disconnect();
db.close();
}
DuckDB and D Types
| DuckDB type | D type | Description |
|---|---|---|
| BOOLEAN | bool | |
| TINYINT | byte | |
| SMALLINT | short | |
| INTEGER | int | |
| BIGINT | long | |
| HUGEINT | BigInt | |
| UTINYINT | ubyte | |
| USMALLINT | ushort | |
| UINTEGER | uint | |
| UBIGINT | ulong | |
| UHUGEINT | BigInt | |
| FLOAT | float | |
| DOUBLE | double | |
| DECIMAL | TODO: Phobos doesn't have BigFloat/BigDecimal, so support is limited | |
| VARCHAR | string | wstring and dstring are also supported |
| BLOB | byte[] | |
| BITSTRING | TODO | |
| ENUM | string | |
| DATE | Date | |
| TIME | TODO but use TIMESTAMP instead | |
| TIMESTAMP | SysTime | TIMESTAMP_NS is not supported because SysTime is hnsecs precision |
| INTERVAL | TODO | |
| ARRAY | T[] | |
| LIST | T[] | |
| MAP | V[K] | |
| STRUCT | struct | Current implementation doesn't check field names |
| UNION | TODO | |
| UUID | TODO |
Special cases
- NULL
Use std.typecons.Nullable to accept NULL for basic types, e.g. Nullable!int.
- Infinity for DATA and TIMESTAMP
Infinity/-Infinity is mapping to .init value, e.g. Date.init and SysTime.init.
TODO
- Support TODO DuckDB types
- Support more APIs
- Prepared Statements
- Appender
- and more
- Improve API design
- Add unittests
Links
DuckDB official site
DuckDB C API document
Copyright
Copyright (c) 2024- Masahiro Nakagawa
License
Distributed under the Boost Software License, Version 1.0.
- 0.0.1 released a year ago
- repeatedly/d-duckdb
- github.com/repeatedly/d-duckdb
- BSL-1.0
- Copyright © 2024, Masahiro Nakagawa
- Authors:
- Dependencies:
- none
- Versions:
-
Show all 5 versions0.2.1 2024-Dec-24 0.2.0 2024-Oct-10 0.1.0 2024-Oct-07 0.0.1 2024-Oct-03 ~main 2024-Dec-24 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
3 downloads this month
-
21 downloads total
-
- Score:
- 0.6
- Short URL:
- duckdb.dub.pm