Install and load
Run these commands in a Haybarn SQL session. The extension is available from the community repository.
INSTALL gdrive FROM community;
LOAD gdrive FROM community;
Using upstream DuckDB? Follow the maintainer’s installation instructions.
Usage example
Unattended: a service account. To WRITE you need a Shared Drive --
-- Unattended: a service account. To WRITE you need a Shared Drive --
-- service accounts have no personal Drive storage quota and get
-- 403 storageQuotaExceeded anywhere else. Reading a shared folder is fine.
--
-- DRIVE_ID is a SHARED DRIVE id; ROOT_FOLDER_ID is a FOLDER id. They are
-- not interchangeable: passing a folder id as DRIVE_ID fails with
-- "Shared drive not found". Use whichever matches what was shared.
CREATE SECRET gdrive (
TYPE gdrive,
PROVIDER service_account,
KEY_FILE '/etc/creds/sa.json',
DRIVE_ID '0ABcDeFgHiJkLmNoPQ', -- or ROOT_FOLDER_ID '1a2b3c...'
DRIVE_SCOPE 'https://www.googleapis.com/auth/drive.readonly'
);
-- Query a file by path. Drive has no path addressing, so each segment
-- costs a lookup; results are cached per secret.
SELECT count(*) FROM 'gdrive://Finance/2026/actuals.parquet';
-- Address a file by id instead: zero resolution calls. Prefer this in
-- generated or stored queries.
SELECT * FROM read_csv('gdrive://id:1a2b3cDeFgHiJkLmNoPQrStUvWxYz');
-- Glob a folder.
SELECT * FROM read_parquet('gdrive://exports/parts/*.parquet');
-- A native Google Sheet is queryable with no manual export: it has no
-- byte stream, so it is served through Drive's CSV export.
SELECT * FROM read_csv('gdrive://Finance/Budget');
-- Write a whole file. Writes are sequential; Drive cannot write at a
-- byte offset, so positional writes raise an error rather than corrupt.
COPY (SELECT * FROM t) TO 'gdrive://reports/out.parquet' (FORMAT parquet);
-- Inspect API calls and cache hits for the session.
SELECT * FROM gdrive_stats();
Provided by DataZooDE. Not yet verified on Haybarn 2.0.0.
Sample data & setupAbout this extension
Registers a gdrive:// filesystem, so any DuckDB path expression can address a file in Google Drive with no download or copy step. Because DuckDB dispatches file access through its virtual filesystem, everything layered on it inherits the scheme: read_parquet, read_csv, COPY, glob, and table formats such as DuckLake — attaching a DuckLake whose DATA_PATH is on Drive works and is tested live.
ATTACH of a DuckDB database file on gdrive:// is NOT supported. DuckDB opens database files through a different path that does not consult the virtual filesystem, so the attempt fails immediately rather than half-working.
Project overview from the community descriptor.
Documentation and resources
Project and build details
- Repository
- DataZooDE/duckdb-gdrive
- License
- MIT
- Maintainers
- jrosskopf
- Written in
- C++
- Build source
ac9b9da229cb- Build definition
- Community descriptor