--- warning: DO NOT CHANGE THIS MANUALLY, THIS IS GENERATED BY https://github.com/duckdb/community-extensions repository, check README there title: mongo excerpt: | DuckDB Community Extensions Integrates DuckDB with MongoDB, enabling direct SQL queries and writes over MongoDB collections without ETL extension: name: mongo description: Integrates DuckDB with MongoDB, enabling direct SQL queries and writes over MongoDB collections without ETL version: 0.5.1 language: C++ build: cmake license: MIT maintainers: - stephaniewang526 vcpkg_commit: "f74a2eade17a628413746557d04db25ccf6e76f9" excluded_platforms: wasm_mvp;wasm_eh;wasm_threads;windows_amd64_mingw; repo: github: stephaniewang526/duckdb-mongo ref: ddd29de6116bd56d66ff1e063afd6ba24c6fabf2 docs: hello_world: | -- Attach to MongoDB ATTACH 'host=localhost port=27017' AS mongo_db (TYPE MONGO); -- Query collections with SQL SELECT * FROM mongo_db.mydb.mycollection LIMIT 10; -- Load a CSV directly into MongoDB INSERT INTO mongo_db.mydb.mycollection SELECT * FROM read_csv('data.csv'); extended_description: | The duckdb-mongo extension provides direct SQL access to MongoDB collections without requiring data export or ETL processes. It supports both standalone MongoDB instances and MongoDB Atlas clusters. **Reading data:** - Automatic schema inference from sampled documents, with nested document flattening - User-provided schemas and Atlas SQL `__schema` document support - Query pushdown to MongoDB for filters (including struct field predicates), projections, limits, TopN, and aggregations (COUNT, SUM, MIN, MAX, AVG) - `VARIANT` columns that keep each value's own BSON type: opt-in per column, as the inference fallback (`nested_type := 'variant'`), or for whole documents (`raw := true`), with path projection and predicate pushdown - `mongo_sample_size` setting to control schema inference sampling - `MongoQuery` log type to inspect the exact commands sent to MongoDB - BSON type mapping including ObjectId, Decimal128, arrays, and nested documents **Writing data:** - `INSERT INTO` -- insert rows from any DuckDB source (CSV, Parquet, other databases, subqueries) - `CREATE TABLE AS SELECT` -- create new MongoDB collections from query results - `COPY TO (FORMAT mongo)` -- bulk-load data into MongoDB collections - `DROP TABLE` -- drop MongoDB collections **Connections and security:** - MongoDB Atlas support via connection strings or DuckDB Secrets, including arbitrary URI options (e.g. `readPreference`) via the secret's `OPTIONS` key - TLS/SSL encryption, custom CA certificates - `mongo_enable_direct_scan` setting to restrict `mongo_scan` to attached catalogs only For detailed setup and usage instructions, visit the [extension repository](https://github.com/stephaniewang526/duckdb-mongo). extension_star_count: 61 extension_star_count_pretty: 61 extension_download_count: 6661 extension_download_count_pretty: 6.7k image: '/images/community_extensions/social_preview/preview_community_extension_mongo.png' layout: community_extension_doc --- ### Compatibility Matrix This table covers all DuckDB releases that have not reached [end-of-life](https://duckdb.org/release_calendar), 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.4.4 | 1.4.5 | 1.5.5 | 1.5.6 | 2.0.0 | | :--- | :---: | :---: | :---: | :---: | :---: | | Linux AMD64 | ✅ | ✅ | ✅ | ✅ | ✅ | | Linux ARM64 | ✅ | ✅ | ✅ | ✅ | ✅ | | macOS AMD64 | ✅ | ✅ | ✅ | ✅ | ✅ | | macOS ARM64 | ✅ | ✅ | ✅ | ✅ | ✅ | | Windows AMD64 | ✅ | ✅ | ✅ | ✅ | ✅ | | Windows ARM64 | ❌ | ❌ | ❌ | ❌ | ❌ | | WebAssembly | ❌ | ❌ | ❌ | ❌ | ❌ | ### Installing and Loading ```sql INSTALL {{ page.extension.name }} FROM community; LOAD {{ page.extension.name }}; ``` {% if page.docs.hello_world %} ### Example ```sql {{ page.docs.hello_world }}``` {% endif %} {% if page.docs.extended_description %} ### About {{ page.extension.name }} {{ page.docs.extended_description }} {% endif %} ### Added Functions
| function_name | function_type | description | comment | examples | |-------------------|---------------|----------------------------------------------------------------------------------------------------------------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | mongo_clear_cache | table | Clears the schema cache for all attached MongoDB databases. Useful when MongoDB schema changes. | NULL | [SELECT * FROM mongo_clear_cache()] | | mongo_scan | table | Scans a MongoDB collection and returns its contents as a table. Supports optional filter and sample_size parameters. | NULL | [SELECT * FROM mongo_scan('mongodb://localhost:27017', 'mydb', 'mycollection'), SELECT * FROM mongo_scan('mongodb://localhost:27017', 'mydb', 'mycollection', filter := '{"status": "active"}')] | ### 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 | |--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|--------|---------|-------------| | mongo_enable_direct_scan | Allow mongo_scan to use a connection string that is not from an attached MongoDB database. When false, mongo_scan is only allowed if the connection string exactly matches an attached Mongo catalog. | BOOLEAN | GLOBAL | [] | true | | mongo_nested_type | How inferred schemas represent nested documents, irregular arrays and type conflicts: 'json' (VARCHAR holding JSON text) or 'variant' (DuckDB VARIANT built from BSON). Applies when mongo_scan is called without an explicit nested_type, including collections queried through an attached catalog; inferred schemas are cached per attached collection, so call mongo_clear_cache() or re-ATTACH after changing this. | VARCHAR | GLOBAL | [] | json | | mongo_sample_size | Number of documents sampled for schema inference when mongo_scan is called without an explicit sample_size, including collections queried through an attached catalog. Inferred schemas are cached per attached collection; call mongo_clear_cache() or re-ATTACH after changing this to re-infer. Must be between 1 and 2147483647. | BIGINT | GLOBAL | [] | 100 | | temp_directory | Set the directory to which temporary files are written. | VARCHAR | GLOBAL | [] | post.db.tmp |