{"title":"Ingest from DuckDB","description":"Ingest data from DuckDB into Altertable with the community extension for local files, tables, and SQL workflows.","order":200,"askSuggestions":["How do I load a local Parquet file with DuckDB?","How do I store lakehouse credentials as a DuckDB secret?","How do I add a column to a remote table?"],"navigation":true,"body":{"code":"var Component=(()=>{var p=Object.create;var l=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var g=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),T=(n,e)=>{for(var r in e)l(n,r,{get:e[r],enumerable:!0})},i=(n,e,r,o)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let t of D(e))!E.call(n,t)&&t!==r&&l(n,t,{get:()=>e[t],enumerable:!(o=b(e,t))||o.enumerable});return n};var f=(n,e,r)=>(r=n!=null?p(A(n)):{},i(e||!n||!n.__esModule?l(r,\"default\",{value:n,enumerable:!0}):r,n)),k=n=>i(l({},\"__esModule\",{value:!0}),n);var h=g((R,d)=>{d.exports=_jsx_runtime});var S={};T(S,{default:()=>m,frontmatter:()=>w});var a=f(h()),w={title:\"Ingest from DuckDB\",description:\"Ingest data from DuckDB into Altertable with the community extension for local files, tables, and SQL workflows.\",order:200,askSuggestions:[\"How do I load a local Parquet file with DuckDB?\",\"How do I store lakehouse credentials as a DuckDB secret?\",\"How do I add a column to a remote table?\"]};function u(n){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",h3:\"h3\",li:\"li\",p:\"p\",pre:\"pre\",strong:\"strong\",ul:\"ul\",...n.components},{CodeSnippet:r,DocsPreviewDocument:o,DocsPreviewSection:t,DocsTable:s}=e;return r||c(\"CodeSnippet\",!0),o||c(\"DocsPreviewDocument\",!0),t||c(\"DocsPreviewSection\",!0),s||c(\"DocsTable\",!0),(0,a.jsxs)(o,{anchors:\"ingest-from-duckdb installation attach-a-database connection-parameters create-a-remote-table load-local-data append-rows update-table-definitions\",children:[(0,a.jsxs)(t,{sectionId:\"ingest-from-duckdb\",sectionTitle:\"Ingest from DuckDB\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,a.jsx)(e.h1,{id:\"ingest-from-duckdb\",children:\"Ingest from DuckDB\"}),`\n`,(0,a.jsxs)(e.p,{children:[\"The \",(0,a.jsx)(e.a,{href:\"https://github.com/altertable-ai/duckdb-altertable\",children:\"DuckDB Altertable extension\"}),\" lets DuckDB write to attached Altertable catalogs. Use it when your data already lives in DuckDB, local files, or a DuckDB-compatible source and you want to load it into Altertable with SQL.\"]}),`\n`,(0,a.jsx)(e.p,{children:\"The extension supports:\"}),`\n`,(0,a.jsxs)(e.ul,{children:[`\n`,(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.strong,{children:\"Attached databases\"}),\" for ingesting into Altertable catalogs with standard SQL\"]}),`\n`,(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.strong,{children:\"Direct table access\"}),\" through DuckDB's catalog\"]}),`\n`,(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.strong,{children:\"Remote writes\"}),\" for bulk loads, appends, and schema updates\"]}),`\n`]}),`\n`]}),(0,a.jsxs)(t,{sectionId:\"installation\",sectionTitle:\"Installation\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,a.jsx)(e.h2,{id:\"installation\",children:\"Installation\"}),`\n`,(0,a.jsx)(e.p,{children:\"Install and load the community extension from DuckDB:\"}),`\n`,(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:\"language-sql\",children:`INSTALL altertable FROM community;\nLOAD altertable;\n`})}),`\n`]}),(0,a.jsxs)(t,{sectionId:\"attach-a-database\",sectionTitle:\"Attach a database\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,a.jsx)(e.h2,{id:\"attach-a-database\",children:\"Attach a database\"}),`\n`,(0,a.jsx)(e.p,{children:\"Use your lakehouse username, lakehouse password, and catalog in the connection string:\"}),`\n`,(0,a.jsx)(r,{language:\"sql\",children:`ATTACH\n  'user={{LAKEHOUSE_USERNAME}} password={{LAKEHOUSE_PASSWORD}} catalog=my_catalog'\n  AS remote_db (TYPE ALTERTABLE);`}),`\n`]}),(0,a.jsxs)(t,{sectionId:\"connection-parameters\",sectionTitle:\"Connection parameters\",anchors:\"\",ancestors:\"attach-a-database\",index:\"3\",children:[(0,a.jsx)(e.h3,{id:\"connection-parameters\",children:\"Connection parameters\"}),`\n`,(0,a.jsx)(s,{columns:[\"Parameter\",\"Description\",\"Example\"],data:[{Parameter:\"`user`\",Description:\"Lakehouse username\",Example:\"`{{LAKEHOUSE_USERNAME}}`\"},{Parameter:\"`password`\",Description:\"Lakehouse password\",Example:\"`{{LAKEHOUSE_PASSWORD}}`\"},{Parameter:\"`catalog`\",Description:\"Remote Altertable catalog\",Example:\"`analytics`\"}]}),`\n`,(0,a.jsx)(e.p,{children:\"Or use DuckDB secrets:\"}),`\n`,(0,a.jsx)(r,{language:\"sql\",children:`CREATE SECRET my_altertable (\n    TYPE altertable,\n    USER '{{LAKEHOUSE_USERNAME}}',\n    PASSWORD '{{LAKEHOUSE_PASSWORD}}',\n    CATALOG 'my_catalog'\n);\n\nATTACH '' AS remote_db (TYPE altertable, SECRET my_altertable);`}),`\n`,(0,a.jsx)(e.p,{children:\"To disconnect the attached catalog:\"}),`\n`,(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:\"language-sql\",children:`DETACH remote_db;\n`})}),`\n`]}),(0,a.jsxs)(t,{sectionId:\"create-a-remote-table\",sectionTitle:\"Create a remote table\",anchors:\"\",ancestors:\"\",index:\"4\",children:[(0,a.jsx)(e.h2,{id:\"create-a-remote-table\",children:\"Create a remote table\"}),`\n`,(0,a.jsx)(e.p,{children:\"Create tables through the attached Altertable database:\"}),`\n`,(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:\"language-sql\",children:`CREATE TABLE remote_db.main.orders (\n    order_id INTEGER,\n    amount DOUBLE,\n    status VARCHAR\n);\n`})}),`\n`]}),(0,a.jsxs)(t,{sectionId:\"load-local-data\",sectionTitle:\"Load local data\",anchors:\"\",ancestors:\"\",index:\"5\",children:[(0,a.jsx)(e.h2,{id:\"load-local-data\",children:\"Load local data\"}),`\n`,(0,a.jsx)(e.p,{children:\"Create an Altertable table from a local DuckDB table:\"}),`\n`,(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:\"language-sql\",children:`CREATE TABLE remote_db.main.orders AS\nSELECT *\nFROM local_db.main.orders;\n`})}),`\n`,(0,a.jsx)(e.p,{children:\"You can also load files that DuckDB can read:\"}),`\n`,(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:\"language-sql\",children:`CREATE TABLE remote_db.main.orders AS\nSELECT *\nFROM read_parquet('orders.parquet');\n`})}),`\n`]}),(0,a.jsxs)(t,{sectionId:\"append-rows\",sectionTitle:\"Append rows\",anchors:\"\",ancestors:\"\",index:\"6\",children:[(0,a.jsx)(e.h2,{id:\"append-rows\",children:\"Append rows\"}),`\n`,(0,a.jsx)(e.p,{children:\"Append new records from a query:\"}),`\n`,(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:\"language-sql\",children:`INSERT INTO remote_db.main.orders\nSELECT order_id, amount, status\nFROM read_csv('new-orders.csv');\n`})}),`\n`,(0,a.jsx)(e.p,{children:\"Append individual rows when you need a quick manual load:\"}),`\n`,(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:\"language-sql\",children:`INSERT INTO remote_db.main.orders VALUES\n    (1001, 42.50, 'open'),\n    (1002, 19.99, 'paid');\n`})}),`\n`]}),(0,a.jsxs)(t,{sectionId:\"update-table-definitions\",sectionTitle:\"Update table definitions\",anchors:\"\",ancestors:\"\",index:\"7\",children:[(0,a.jsx)(e.h2,{id:\"update-table-definitions\",children:\"Update table definitions\"}),`\n`,(0,a.jsxs)(e.p,{children:[\"Use \",(0,a.jsx)(e.code,{children:\"ALTER TABLE\"}),\" when incoming data needs a new column:\"]}),`\n`,(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:\"language-sql\",children:`ALTER TABLE remote_db.main.orders ADD COLUMN note VARCHAR;\n`})}),`\n`,(0,a.jsxs)(e.p,{children:[\"For Python DataFrame workflows, see \",(0,a.jsx)(e.a,{href:\"/docs/lakehouse/ingest/pandas-polars-ibis\",children:\"Ingest with Pandas, Polars, and Ibis\"}),\". For querying attached Altertable tables from DuckDB, see \",(0,a.jsx)(e.a,{href:\"/docs/lakehouse/query/duckdb\",children:\"Query data with DuckDB\"}),\". For more examples and source builds, see the \",(0,a.jsx)(e.a,{href:\"https://github.com/altertable-ai/duckdb-altertable\",children:\"DuckDB Altertable extension repository\"}),\".\"]}),`\n`,(0,a.jsxs)(e.p,{children:[\"For other DuckDB workflows, see the \",(0,a.jsx)(e.a,{href:\"/docs/lakehouse/integrations/duckdb\",children:\"DuckDB integration hub\"}),\".\"]})]})]})}function m(n={}){let{wrapper:e}=n.components||{};return e?(0,a.jsx)(e,{...n,children:(0,a.jsx)(u,{...n})}):u(n)}function c(n,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+n+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return k(S);})();\n;return Component;"},"_id":"docs/lakehouse/ingest/duckdb.mdx","_raw":{"sourceFilePath":"docs/lakehouse/ingest/duckdb.mdx","sourceFileName":"duckdb.mdx","sourceFileDir":"docs/lakehouse/ingest","contentType":"mdx","flattenedPath":"docs/lakehouse/ingest/duckdb"},"type":"Docs","path":"/lakehouse/ingest/duckdb","level":3,"parent":"lakehouse/ingest"}