Status of the DuckDB driver
Posted: 12.01.2025, 13:56
Sooo - I think the DuckDB driver is finally ready for some first experiments by others. The driver is not finished yet. But it can be used to execute queries and fetch result sets. Results cannot be updated automatically yet. To make a result updateable, you need to use TZUpdateSQL.
The DuckDb driver is not included in the packages yet. To use it you will have to install Zeos into your IDE as usual. Then you need to create a new project and add the Zeos source folders (src/core, src/parsesql, src/plain, src/dbc, src/component) to the unit search path, so the DuckDB units can be found. Then you need to add the ZDbcDuckDB unit to your project. This will make the DuckDB driver available to your application.
The following code will create a database or open it, if it already exists:
There still is a lot of work to do, so don't be surprised if something doesn't work: Transactions are not implemented. Some data types also are not implemented (yet). The following data types should work: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, UTINYINT, USMALLINT, UINTEGER, UBIGINT, FLOAT, DOUBLE, TIMESTAMP, DATE, TIME, VARCHAR (mapped to TMemoField), BLOB, DECIMAL.
Varchar is mapped to TMemoField because varchars in DuckDB are not restricted in length and there is not even a hint what the developer has intended for lenght.
The driver still has shortcomings, they are documented in the Wiki: https://sourceforge.net/p/zeoslib/wiki/DuckDB/
Opinion? Questions?
The DuckDb driver is not included in the packages yet. To use it you will have to install Zeos into your IDE as usual. Then you need to create a new project and add the Zeos source folders (src/core, src/parsesql, src/plain, src/dbc, src/component) to the unit search path, so the DuckDB units can be found. Then you need to add the ZDbcDuckDB unit to your project. This will make the DuckDB driver available to your application.
The following code will create a database or open it, if it already exists:
Code: Select all
begin
ZConnection.Protocol := 'DuckDB';
ZConnection.LibraryLocation := 'C:\Projects\Zeos\clientlibs\duckdb-1.1.3\duckdb.dll';
ZConnection.ClientCodepage := 'UTF8';
ZConnection.Database := 'C:\Users\marsupilami\Documents\test.duckdb';
ZConnection.Connect;
ShowMessage('Connected');
end;
Varchar is mapped to TMemoField because varchars in DuckDB are not restricted in length and there is not even a hint what the developer has intended for lenght.
The driver still has shortcomings, they are documented in the Wiki: https://sourceforge.net/p/zeoslib/wiki/DuckDB/
Opinion? Questions?