Skip to main content

Flights functions

Preview
Flights is in Preview. Underlying infrastructure is still evolving and may change before general availability. We recommend avoiding workloads with regulated or sensitive data on Flights during Preview.

SQL table functions for managing Flights, MotherDuck's scheduled Python execution. Use these functions from any MotherDuck client (DuckDB CLI, BI tool, or another Flight) to create, schedule, list, and monitor Flights without leaving SQL.

The MCP server exposes the same operations to AI agents through create_flight, list_flights, run_flight, and so on. The MCP and SQL surfaces use slightly different parameter names — see each function page for the details, or read the Flights MCP reference for the agent-facing tools.

note

These functions execute server-side on MotherDuck. They are not available on local-only DuckDB connections.

A minimal end-to-end Flight from SQL:

-- Create the Flight
SELECT flight_id, current_version
FROM MD_CREATE_FLIGHT(
name := 'heartbeat',
source_code := $$
import duckdb

def main():
con = duckdb.connect("md:")
con.execute("CREATE DATABASE IF NOT EXISTS flights_demo")
print("ok")

if __name__ == "__main__":
main()
$$,
requirements_txt := 'duckdb==1.5.3'
);

-- Trigger an on-demand run
CALL MD_RUN_FLIGHT(flight_id := '<flight_id>');

-- Inspect the run
SELECT run_number, status, created_at
FROM MD_LIST_FLIGHT_RUNS(flight_id := '<flight_id>')
ORDER BY run_number DESC LIMIT 1;

Available functions