Search Shortcut cmd + k | ctrl + k

SharePoint and OneDrive in SQL – files (sharepoint://), Excel workbooks, SharePoint lists, search and change feeds

Maintainer(s): jrosskopf, sipemu

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 sharepoint FROM community;
LOAD sharepoint;

Example

-- App-only auth: an Entra ID app registration with the Sites.ReadWrite.All
-- APPLICATION permission and admin consent. Bind it to a document library
-- by DRIVE_ID (a Graph drive id) or SITE_ID.
CREATE SECRET sp (
    TYPE sharepoint,
    PROVIDER client_credentials,
    TENANT_ID '00000000-0000-0000-0000-000000000000',
    CLIENT_ID '11111111-1111-1111-1111-111111111111',
    CLIENT_SECRET '...',
    DRIVE_ID 'b!AbCdEf...'
);

-- Read a file by path -- one Graph call, no per-segment walk.
SELECT count(*) FROM 'sharepoint://Finance/2026/actuals.parquet';

-- Address by driveItem id instead -- stable across a rename.
SELECT * FROM read_csv('sharepoint://id:01ABCDEF23456789');

-- Glob a folder.
SELECT * FROM read_parquet('sharepoint://exports/parts/*.parquet');

-- Write a file. Sequential only; streamed in bounded memory.
COPY (SELECT * FROM t) TO 'sharepoint://reports/out.parquet' (FORMAT parquet);

About sharepoint

Registers a sharepoint:// filesystem backed by Microsoft Graph, so any DuckDB path expression can address a file in a SharePoint document library or OneDrive with no download step. Because DuckDB dispatches file access through its virtual filesystem, read_parquet, read_csv, COPY, glob and DuckLake all inherit the scheme.

Unlike Google Drive, Graph addresses items by path, so there is no path-resolution cache and no duplicate-name ambiguity. Reads are ranged and served from a block cache. Writes stream through a Graph upload session in bounded memory and the file appears when it is closed (Graph cannot write at a byte offset, so positional writes raise rather than corrupt). Beyond files: read_excel_table / read_excel_range read live Excel workbooks and COPY ... (FORMAT excel_table | excel_range) writes them back; read_sharepoint_list reads SharePoint lists as typed tables (WHERE pushed down to Graph on indexed columns) and COPY ... (FORMAT sharepoint_list) creates or updates items; read_sharepoint_files lists a library with its metadata; search_sharepoint runs Microsoft Search; sharepoint_changes / sharepoint_list_changes return what changed since a token; ?version= reads an earlier version of a file. ATTACH a site to see its lists (and, with WORKBOOKS, Excel tables) in the catalog; the excel extension's read_xlsx / FORMAT xlsx work on sharepoint:// paths; read_docx reads Word documents and COPY ... (FORMAT docx, TEMPLATE ...) fills templates; read_onenote_pages, read_outlook_messages, read_planner_tasks / read_todo_tasks and sharepoint_permissions reach OneNote, Outlook mail, tasks and sharing. Besides app-only client credentials or a certificate, a user can sign in with device_code or authorization_code. Also registers the scheme-generic write_blob, remove_file, move_file and file_size SQL functions, which work for any filesystem DuckDB can reach.

This is SharePoint / OneDrive via Microsoft Graph, not Azure Blob Storage — a different product with a different API. For az:///abfss:// containers use the azure extension.

Added Functions

function_name function_type description comment examples
file_size scalar Byte length of the file at path, or NULL if it does not exist. Reads only metadata – unlike read_blob, which downloads the body. NULL [SELECT file_size('data/part.parquet')]
move_file scalar Rename/move source to target, returning true on success and raising on failure. Both paths must live on the SAME filesystem – this is a rename, not a copy. Its main use is publishing a fully-written temporary file under its final name. NULL [SELECT move_file('staging/part.tmp', 'data/part.parquet')]
read_docx table The paragraphs of Word documents (.docx; a path or glob, sharepoint:// or any filesystem): file, idx (1-based), style, heading_level (1-9 for Heading1..9) and text. Paragraphs inside tables are left to read_docx_table. NULL [SELECT file, text FROM read_docx('sharepoint://Contracts/*.docx') WHERE text ILIKE '%notice period%']
read_docx_table table The n-th table (default 1) of a Word document (.docx): its first row names the columns, every value is text (a cell's paragraphs joined by newlines). NULL [SELECT * FROM read_docx_table('sharepoint://Reports/q4.docx', 2)]
read_excel_range table Read a range of an .xlsx in SharePoint / OneDrive, live through the Graph workbook API: 'Sheet!A1:F200', or a sheet name for its used range. The first row is the header unless header := false. all_varchar := true reads every column as text. NULL [SELECT * FROM read_excel_range('Finance/plan.xlsx', 'Input!A1:F200'), SELECT * FROM read_excel_range('Finance/plan.xlsx', 'Input', header := false)]
read_excel_table table Read a named Excel table from an .xlsx in SharePoint / OneDrive, live through the Graph workbook API: the header row gives the column names, the values and number formats the types (dates included). The path is a sharepoint:// path (the scheme may be left out) or id:. all_varchar := true reads every column as text. NULL [SELECT * FROM read_excel_table('Finance/plan.xlsx', 'Sales')]
read_onenote_pages table The pages of a site's OneNote notebooks (default the secret's site; notebook := and section := narrow it): notebook, section, title, created and modified times, web address and id; content := true adds each page's HTML (one request per page). OneNote has no delta: track changes with WHERE modified > . Needs a signed-in user with Notes.Read (Microsoft restricts app-only OneNote access). Write pages with COPY ... TO '/<section>' (FORMAT onenote). NULL [SELECT section, title, modified FROM read_onenote_pages(notebook := 'Projects') ORDER BY modified DESC, SELECT title, content FROM read_onenote_pages(notebook := 'Projects', section := 'Q4', content := true)]
read_outlook_messages table The signed-in user's Outlook messages (or user := someone's, app-only), newest first: received and sent times, subject, sender, recipients, flags, categories, conversation id, preview and web address. folder := a well-known folder (inbox, sentitems, drafts, archive, …) or a top-level folder's name; since := only messages received from then on; body := true adds the body as text. Needs Mail.Read (delegated or application). NULL [SELECT received, from_email, subject FROM read_outlook_messages(folder := 'inbox', since := TIMESTAMP '2026-11-01'), SELECT * FROM read_outlook_messages(user := '[email protected]', folder := 'inbox') LIMIT 50]
read_planner_tasks table The tasks of a Microsoft Planner plan, by its id, or by its name (with group := for app-only): bucket, title, status, percent complete, priority, start/due/completed dates and the assigned user ids. Needs Tasks.Read.All (application) or Tasks.Read (delegated). NULL [SELECT * FROM read_planner_tasks('Q1 launch', group := '')]
read_sharepoint_files table A document library's files and their metadata, one row per file matching a sharepoint:// path or glob: path, name, size, created/modified and by whom, content type, id, web URL, then the library's own columns, typed as read_sharepoint_list types a list's. NULL [SELECT name, size, modified_by FROM read_sharepoint_files('sharepoint://Finance/*/.xlsx')]
read_sharepoint_list table Read a SharePoint list as a table through Microsoft Graph: one row per item, one typed column per list column (named by its display name), plus id, created and modified. The list is named by its name or as id:; it is on the secret's site unless site := names another ('Sales', 'teams/Ops', or a Graph site id). Lookup and person columns give their item id as _id. NULL [SELECT * FROM read_sharepoint_list('Orders'), SELECT * FROM read_sharepoint_list('Orders', site := 'Sales')]
read_sharepoint_list_attachments table The files attached to a SharePoint list's items: item_id, file_name, url and content (BLOB, downloaded only when selected). Uses SharePoint's own API (Microsoft Graph has none for attachments), which needs a certificate or a user sign-in – not a client secret – and a SharePoint API permission. NULL [SELECT item_id, file_name FROM read_sharepoint_list_attachments('Orders', site := 'Sales'), SELECT content FROM read_sharepoint_list_attachments('Orders', item_id := 7)]
read_todo_tasks table The signed-in user's Microsoft To Do tasks (or user := someone's, app-only): list, title, status, importance, due/completed dates and body. list := picks one list. Needs Tasks.Read (delegated) or Tasks.Read.All (application). NULL [SELECT * FROM read_todo_tasks() WHERE status <> 'completed']
remove_file scalar Delete the file at path, returning true if it existed and was removed and false if it did not exist. Dispatches on the path's scheme through DuckDB's virtual filesystem, so it works for local paths and for every remote scheme an extension registers (gdrive://, sharepoint://, s3://, …). Remote stores may keep a deleted file in a trash or recycle bin (see the extension's *_permanent_delete setting). Folders are refused. Errors other than not-found are raised, not returned as false. NULL [SELECT remove_file('reports/old.parquet')]
search_sharepoint table Microsoft Search across the tenant's files, list items and sites (types := ['driveItem', 'listItem', 'site']), as rows: type, name, a sharepoint:// path for a file in the secret's drive, id, web URL, drive, site and list ids, size, times, who modified it, the hit summary and its rank. App-only search finds the tenant's region itself, or takes region := 'EUR'. NULL [SELECT name, path, modified FROM search_sharepoint('quarterly forecast'), SELECT name, web_url FROM search_sharepoint('Sales', types := ['site'])]
sharepoint_changes table What changed under a sharepoint:// folder since a token (Graph's delta query): one row per file or folder added or changed (_change 'upsert') or deleted ('delete'), then one 'checkpoint' row whose token column is the token for next time. Without a token: everything (a full listing); token := 'latest': nothing, just a token from now on. A folder renamed or moved in brings its subtree. outside := true also reports what left the folder (moved out, with its subtree) as path-less deletes – what a mirror needs. NULL [SELECT * FROM sharepoint_changes('sharepoint://Finance/'), SELECT * FROM sharepoint_changes('sharepoint://Finance/', token := 'aTE09…')]
sharepoint_drives table The document libraries of a site (its browser address, 'Sales', 'sites/Sales' or a Graph id; default the secret's site): name (use it as DRIVE), web address, drive id (DRIVE_ID), type and description. NULL [SELECT name, web_url, id FROM sharepoint_drives('https://contoso.sharepoint.com/sites/Sales')]
sharepoint_list_changes table The items of a SharePoint list added, changed or deleted since a token (Graph's delta query): the list's columns as read_sharepoint_list gives them, then _change ('upsert', 'delete' – only id is set – or 'checkpoint') and token, set on the one checkpoint row: the token for next time. No token: every item; token := 'latest': none, just a token. NULL [SELECT * FROM sharepoint_list_changes('Orders', token := 'aTE09…')]
sharepoint_permissions table Who can reach a file or folder (or the files and folders a glob matches): one row per grantee of each permission – roles, granted_by (direct, inherited, link), the user, group or app, and for a sharing link its type, scope (anonymous, organization, users) and address. NULL [SELECT path, grantee, roles, link_scope FROM sharepoint_permissions('sharepoint://Finance/**')]
sharepoint_reset_stats table Zero the counters reported by sharepoint_stats(). Process-wide: it disturbs a concurrent measurement in another connection. NULL [CALL sharepoint_reset_stats()]
sharepoint_sites table The SharePoint sites the credentials can see (search := filters by words in the name): display name, web address (use it as SITE_URL or in a path), URL name, description and Graph id. Works before the secret names a drive. NULL [SELECT name, web_url FROM sharepoint_sites(), SELECT * FROM sharepoint_sites(search := 'Sales')]
sharepoint_stats table Microsoft Graph call counters, one row per metric: token_request, stat, read_range, list_page, upload_put, upload_session, upload_chunk, upload_commit, upload_abort, delete, move, create_folder (calls by kind), retries, throttled, bytes_read, bytes_written, meta_cache_hits (opens served from the sharepoint_immutable_prefixes metadata cache), auth_refresh (401s answered by a fresh token), workbook (Excel workbook API calls), list (SharePoint site/list/item pages) and upload_buffer_peak (a HIGH-WATER MARK: the most bytes one file being written held in memory). Process-wide; reset with sharepoint_reset_stats() to measure what one query costs. NULL [SELECT * FROM sharepoint_stats()]
sharepoint_version scalar Returns the version of the loaded sharepoint extension. NULL [SELECT sharepoint_version()]
sharepoint_versions table A SharePoint file's version history, newest first: the version label, a path that reads that version (sharepoint://…?version= NULL [SELECT * FROM sharepoint_versions('sharepoint://Finance/plan.xlsx'), SELECT * FROM read_parquet('sharepoint://Finance/actuals.parquet?version=3.0')]
write_blob scalar Write content to path, replacing any existing file, and return the number of bytes written. The inverse of read_blob(): together they give SQL a byte-exact round trip for any filesystem DuckDB can reach, local or remote. Accepts arbitrary binary content – a BLOB, not a VARCHAR. NULL [SELECT write_blob('notes/readme.md', '# Title'::BLOB)]

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
datazoo_banner Show the DataZoo feedback banner when an extension is loaded in an interactive terminal (at most once a day per extension). BOOLEAN GLOBAL [] true
sharepoint_block_size_bytes Block size for cached reads (default 8 MiB, at most 64 MiB; 0 disables the cache and reads exact ranges). UBIGINT GLOBAL [] 8388608
sharepoint_debug_token_max_age_seconds TESTING ONLY: treat access tokens as expiring after at most this many seconds (0 = their real lifetime). BIGINT GLOBAL [] 0
sharepoint_device_code_timeout_seconds How long PROVIDER device_code waits for the user to finish signing in (default 900, at most 3600; also capped by the device code's own lifetime). BIGINT GLOBAL [] 900
sharepoint_graph_endpoint Base URL for Microsoft Graph (default https://graph.microsoft.com). Set for national clouds such as https://graph.microsoft.us or https://microsoftgraph.chinacloudapi.cn. VARCHAR GLOBAL [] https://graph.microsoft.com
sharepoint_immutable_prefixes Comma-separated sharepoint:// path prefixes whose files are never overwritten in place (e.g. a DuckLake DATA_PATH). Skips the per-open metadata refresh for them. Matching is on whole path segments. Empty (the default) disables it. VARCHAR GLOBAL []  
sharepoint_list_page_size Items per Graph page when reading a SharePoint list (default 999, between 1 and 999). BIGINT GLOBAL [] 999
sharepoint_login_endpoint Base URL for the Azure AD login authority (default https://login.microsoftonline.com). Set for national clouds, e.g. https://login.microsoftonline.us. VARCHAR GLOBAL [] https://login.microsoftonline.com
sharepoint_permanent_delete RemoveFile permanently deletes instead of moving to the recycle bin (default: false). BOOLEAN GLOBAL [] false
sharepoint_telemetry_enabled Enable or disable anonymous usage telemetry for the sharepoint extension. BOOLEAN GLOBAL [] true
sharepoint_upload_chunk_bytes Upload chunk size, and the most memory one file being written holds (default 10 MiB; rounded down to a multiple of 320 KiB and capped below 60 MiB per the Graph upload-session contract). Files up to this size upload in one PUT on close; larger ones stream through a resumable upload session as they are written. UBIGINT GLOBAL [] 10485760
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