This is the implementation of the DuckDB data handler for MindsDB.

DuckDB is an open-source analytical database system. It is designed for fast execution of analytical queries. There are no external dependencies and the DBMS runs completely embedded within a host process, similar to SQLite. DuckDB provides a rich SQL dialect with support for complex queries with transactional guarantees (ACID).


Before proceeding, ensure the following prerequisites are met:

  1. Install MindsDB locally via Docker or use MindsDB Cloud.
  2. To connect DuckDB to MindsDB, install the required dependencies following this instruction.
  3. Install or ensure access to DuckDB.


This handler is implemented using the duckdb Python client library.

The DuckDB handler is currently using the 0.7.1.dev187 pre-relase version of the Python client library. In case of issues, make sure your DuckDB database is compatible with this version. See the requirements.txt for details.

The required arguments to establish a connection are as follows:

  • database is the name of the DuckDB database file. It can be set to :memory: to create an in-memory database.

The optional arguments are as follows:

  • read_only is a flag that specifies whether the connection is in the read-only mode. This is required if multiple processes want to access the same database file at the same time.


In order to make use of this handler and connect to the DuckDB database in MindsDB, the following syntax can be used:

CREATE DATABASE duckdb_datasource
    engine = 'duckdb',
    parameters = {
        "database": "db.duckdb"

You can use this established connection to query your table as follows:

FROM duckdb_datasource.my_table;