Search Shortcut cmd + k | ctrl + k

Use DuckDB as your data warehouse. BI tools, psql, and other PostgreSQL or Arrow Flight SQL clients can connect and query your DuckDB tables and your Iceberg, DuckLake, or Parquet data. Authentication, TLS, and role-based access control are built in.

Maintainer(s): nicosuave

Compatibility Matrix

This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.

Platform 1.5.5 1.5.6 2.0.0 2.0.1
Linux AMD64
Linux ARM64
macOS AMD64
macOS ARM64
Windows AMD64
Windows ARM64
WebAssembly

Installing and Loading

INSTALL duckflight FROM community;
LOAD duckflight;

Example

-- Create the first administrator. The password is generated and returned once.
SELECT * FROM duckflight_init('alice');

CREATE TABLE trips AS SELECT 1 AS id, 'Lisbon' AS city;

-- Serve this database to PostgreSQL clients.
SELECT * FROM duckflight_serve('postgres', '127.0.0.1:5433');

-- From another terminal:
--   psql "host=127.0.0.1 port=5433 user=alice dbname=memory"
--   SELECT * FROM trips;
--   CREATE USER bob ROLE reader;

About duckflight

DuckFlight lets other programs connect to DuckDB and run queries, the way they would with a data warehouse. psql, JDBC, SQLAlchemy and BI tools connect as if it were PostgreSQL. ADBC drivers connect over Arrow Flight SQL, and another DuckDB can attach it as a catalog.

Clients can query anything that DuckDB can: its own tables, attached databases, Iceberg and DuckLake catalogs, and Parquet or CSV files in object storage. Everything runs inside the DuckDB process that loaded the extension, so there is nothing else to deploy and no data to copy. It works on a laptop, and a Docker image and Helm chart are available for running it for a team.

Clients can connect over four protocols, which can run at the same time. One function, duckflight_serve(protocol, address), starts each of them:

Protocol protocol Clients Credentials
PostgreSQL wire postgres psql, Psycopg, JDBC, SQLAlchemy, BI tools Passwords, tokens, OIDC, mTLS
Arrow Flight SQL flight ADBC drivers, DuckDB's Airport extension Passwords, tokens, OIDC, mTLS
HTTP (Arrow IPC) http Anything that can POST JSON and read Arrow Tokens, OIDC, mTLS
Quack quack Another DuckDB, through its quack extension Tokens, OIDC, mTLS

Every listener requires authentication, and an address other than loopback also requires TLS. Users live in an account store beside the database and are managed with SQL through any listener: CREATE USER, ALTER USER, DROP USER and CREATE TOKEN ... FOR USER. Each user has the role reader, writer or admin, and one account works on all four protocols with its password or its tokens. Changes apply to running listeners at once. No config file is needed; an optional duckflight.toml adds TLS, OIDC providers and client-certificate identities. On DuckDB 2.0.1, SQL-managed roles can also restrict clients to specific tables, columns and rows, with column masks and row filters.

Version 0.2.0 replaced duckflight_pg_serve, duckflight_flight_serve, duckflight_http_serve and duckflight_quack_serve with duckflight_serve. Users and tokens in an existing duckflight.toml keep working until the account store is created, and duckflight_import moves them into it.

Functions that start, stop and list listeners:

Function Purpose
duckflight_serve(protocol, address, config_file := '') Starts a listener for postgres, flight, http or quack and returns its protocol and bound address.
duckflight_servers() Lists running listeners and their bound addresses.
duckflight_stop(protocol, address) Stops a listener and returns its status.
duckflight_core_status() Reports whether the runtime loaded, with a reason when it did not.

Functions that manage accounts from the DuckDB process that owns the database:

Function Purpose
duckflight_init(admin) Creates the account store and its first administrator, and returns a generated password once. password_file supplies your own.
duckflight_user_add(name, role := 'reader') Adds a user and returns a generated password once.
duckflight_token_add(user, token_name) Adds a token for a user and returns it once.
duckflight_accounts() Lists users with their roles and credentials.
duckflight_import(config_file) Moves users and tokens from an older duckflight.toml into the account store.
duckflight_config_check(config_file) Validates a config file the way a listener does and reports what it defines.

Only the DuckDB process that owns the database can call these functions. A client connected through a listener cannot, whatever its role; administrators manage accounts there with the SQL statements above. Secrets are never function arguments, and the store holds only digests and password verifiers.

DuckFlight runs on Linux and macOS, on amd64 and arm64. See the quickstart, client examples, authentication and SQL access controls.

The automatically detected functions below also include PostgreSQL compatibility macros, such as to_char and quote_ident, and internal session and catalog helpers. They let PostgreSQL queries and client metadata discovery work; they are not a complete implementation of PostgreSQL's functions. Their catalog comments describe each one. The native functions in the tables above have no catalog descriptions, because the table-function C API they use does not provide a way to set them.

Added Functions

function_name function_type description comment examples
array_ndims macro NULL PostgreSQL compatibility: Returns the number of array dimensions from its type.  
array_remove macro NULL PostgreSQL compatibility: Filters array elements using inequality with the supplied value.  
array_replace macro NULL PostgreSQL compatibility: Replaces matching array elements with a new value.  
btrim macro NULL PostgreSQL compatibility: Trims the specified characters from both ends of a string.  
cardinality macro NULL PostgreSQL compatibility: Returns the length of the first array dimension.  
div macro NULL PostgreSQL compatibility: Divides two numbers and truncates the result to an integer.  
duckflight_array_lower macro NULL NULL  
duckflight_array_matches_first macro NULL NULL  
duckflight_array_upper macro NULL NULL  
duckflight_config_check table NULL NULL  
duckflight_core_status table NULL NULL  
duckflight_current_database macro NULL Internal session helper: Supplies the PostgreSQL-facing database name for compatibility queries.  
duckflight_current_user macro NULL Internal session helper: Supplies the PostgreSQL-facing user name for compatibility queries.  
duckflight_database_oid macro NULL Internal catalog helper: Maps a database name to a PostgreSQL-compatible object identifier.  
duckflight_flight_serve table NULL NULL  
duckflight_http_serve table NULL NULL  
duckflight_pg_generate_series table_macro NULL Internal query helper: Generates a series with PostgreSQL-compatible result typing.  
duckflight_pg_serve table NULL NULL  
duckflight_pg_stat_activity table_macro NULL Internal catalog helper: Supplies PostgreSQL-compatible session activity rows.  
duckflight_pg_stat_ssl table_macro NULL Internal catalog helper: Supplies PostgreSQL-compatible session TLS metadata.  
duckflight_quack_serve table NULL NULL  
duckflight_runtime_databases table_macro NULL Internal catalog helper: Supplies runtime database names for PostgreSQL catalog queries.  
duckflight_servers table NULL NULL  
duckflight_session_pid macro NULL Internal session helper: Supplies the PostgreSQL session process identifier.  
duckflight_stop table NULL NULL  
duckflight_token_create table NULL NULL  
duckflight_user_create table NULL NULL  
duckflight_visible_database macro NULL Internal session helper: Identifies the DuckDB database exposed by compatibility catalog views.  
every macro NULL PostgreSQL compatibility: Computes Boolean AND across input rows.  
format macro NULL PostgreSQL compatibility: Substitutes one value into %I identifier and %s string placeholders.  
initcap macro NULL PostgreSQL compatibility: Capitalizes space-separated words.  
json_agg macro NULL PostgreSQL compatibility: Aggregates input values into a JSON array.  
json_extract_path macro NULL PostgreSQL compatibility: Extracts a JSON value at the supplied object path.  
json_extract_path_text macro NULL PostgreSQL compatibility: Extracts text at the supplied JSON object path.  
json_object_agg macro NULL PostgreSQL compatibility: Aggregates key-value pairs into a JSON object.  
json_typeof macro NULL PostgreSQL compatibility: Reports a JSON value type using PostgreSQL-style names.  
jsonb_array_length macro NULL PostgreSQL compatibility: Returns the number of elements in a JSON array.  
jsonb_set macro NULL PostgreSQL compatibility: Applies a JSON merge patch using the supplied path as an object key.  
octet_length macro NULL PostgreSQL compatibility: Returns the byte length of a blob or UTF-8 string.  
pg_div macro NULL PostgreSQL compatibility: Uses truncated division for integer operands and ordinary division otherwise.  
pg_typeof macro NULL PostgreSQL compatibility: Reports a value type using PostgreSQL-style names.  
quote_ident macro NULL PostgreSQL compatibility: Quotes an SQL identifier when required by the shim identifier rules.  
quote_literal macro NULL PostgreSQL compatibility: Quotes a string as an SQL literal, escaping single quotes.  
quote_nullable macro NULL PostgreSQL compatibility: Quotes a value as an SQL literal or returns the text NULL.  
to_char macro NULL PostgreSQL compatibility: Formats dates, timestamps, or numbers using supported format patterns.  
to_date macro NULL PostgreSQL compatibility: Parses a date using supported format patterns.  
to_json macro NULL PostgreSQL compatibility: Converts a value to JSON.  
to_jsonb macro NULL PostgreSQL compatibility: Converts a value to DuckDB JSON for PostgreSQL jsonb-style queries.  
to_timestamp macro NULL PostgreSQL compatibility: Parses a timestamp with time zone using supported format patterns.  
width_bucket macro NULL PostgreSQL compatibility: Assigns a number to an equal-width bucket, including out-of-range buckets.  

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

name description input_type scope aliases typed_value
temp_directory Set the directory to which temporary files are written. VARCHAR GLOBAL [] post.db.tmp
© 2026 DuckDB Foundation, Amsterdam NL
DuckDB Home Code of Conduct Trademark Use Blog