Repository navigation
Conversation
DuckDB is an in-process analytical database, so the connector targets analytical SQL (window functions, CTEs, file readers, Parquet) rather than trying to mirror sqlite3. The connector is header-only and built on DuckDB's C API. It provides connection, connection_config, connection_pool, prepared statements, transactions, attach and interrupt, plus the insert_or_replace and insert_or_ignore shorthands, and supports returning, on_conflict and the using clause of delete_from. Where DuckDB differs from sqlite3, the connector follows DuckDB: - parameters are plain ? placeholders bound by position (not ?1, ?2, ...), - blobs are serialized as '\xNN'::BLOB, since DuckDB has no x'...' literal, - unsigned_integral maps to the native UBIGINT type instead of being bound as int64, - IS [NOT] DISTINCT FROM uses the SQL standard spelling. DuckDB parses FOR UPDATE and FOR SHARE but rejects the locking clause with "SELECT locking clause is not supported", so compatibility_check rejects for_update at compile time. DuckDB has no last_insert_rowid(), so last_insert_id() is 0 unless the statement has a RETURNING clause. Auto-incrementing columns should use a sequence, as the test tables do. A database file can only be opened once per process, so the connection handle keeps one reference counted duckdb_database per path. That is what makes connection pools work. DuckDB uses snapshot isolation and does not expose a configurable per-connection isolation level, so get_default_isolation_level() always reports serializable and setting anything else throws. The connector lives in include/sqlpp23/duck_db (namespace sqlpp::duck_db), while the CMake component is called DuckDB to match the package name and Sqlpp23DuckDBConfig.cmake. Build with -DBUILD_DUCK_DB_CONNECTOR=ON and make DuckDB findable, e.g. -DDuckDB_DIR=<dir with duckdb.h and duckdb.lib>.
docs/connectors/duck_db.md covers creating connections, sharing a file between connections and pools, parameter placeholders, the insert_or_* shorthands, returning, last_insert_id (RETURNING is required), on_conflict, delete_from ... using, for_update, attach, transactions and isolation levels, exceptions, multi-statement input, blobs and the data type mapping. It also lists how the connector differs from the sqlite3 connector, which is the part users are most likely to trip over.
Owner
|
Hi, Thanks for sending this PR! I admit, I have never heard of DuckDB before :-) As of now, I am not super sure whether I would rather maintain the connector in the main library or prefer a separate repository to maintain it. In any case, here are some comments:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DuckDB is an in-process analytical database, so the connector targets
analytical SQL (window functions, CTEs, file readers, Parquet) rather than
trying to mirror sqlite3.
The connector is header-only and built on DuckDB's C API. It provides
connection, connection_config, connection_pool, prepared statements,
transactions, attach and interrupt, plus the insert_or_replace and
insert_or_ignore shorthands, and supports returning, on_conflict and the
using clause of delete_from.