- Notifications
You must be signed in to change notification settings - Fork57
License
duckdb/duckdb-postgres
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The Postgres extension allows DuckDB to directly read and write data from a running Postgres database instance. The data can be queried directly from the underlying Postgres database. Data can be loaded from Postgres tables into DuckDB tables, or vice versa.
To make a Postgres database accessible to DuckDB use theATTACH
command:
ATTACH'dbname=postgresscanner'AS postgres_db (TYPE postgres);
TheATTACH
command takes as input alibpq
connection string - which is a set ofkey=value
pairs separated by spaces. Below are some example connection strings and commonly used parameters. A full list of available parameters can be foundin the Postgres documentation.
dbname=postgresscannerhost=localhost port=5432 dbname=mydb connect_timeout=10
Name | Description | Default |
---|---|---|
host | Name of host to connect to | localhost |
hostaddr | Host IP address | localhost |
port | Port Number | 5432 |
user | Postgres User Name | [OS user name] |
password | Postgres Password | |
dbname | Database Name | [user] |
passfile | Name of file passwords are stored in | ~/.pgpass |
The tables in the file can be read as if they were normal DuckDB tables, but the underlying data is read directly from Postgres at query time.
D SHOW ALL TABLES;┌───────────────────────────────────────┐│ name ││varchar │├───────────────────────────────────────┤│ uuids │└───────────────────────────────────────┘DSELECT*FROMpostgres_db.uuids;┌──────────────────────────────────────┐│ u ││ uuid │├──────────────────────────────────────┤│ 6d3d2541-710b-4bde-b3af-4711738636bf ││NULL ││00000000-0000-0000-0000-000000000001 ││ ffffffff-ffff-ffff-ffff-ffffffffffff │└──────────────────────────────────────┘
For more information on how to use the connector, refer to thePostgres documentation on the website.
The DuckDB submodule must be initialized prior to building.
git submodule initgit pull --recurse-submodules
To build, type
make
To run, run the bundledduckdb
shell:
./build/release/duckdb -unsigned # allow unsigned extensions
Then, load the Postgres extension like so:
LOAD'build/release/extension/postgres_scanner/postgres_scanner.duckdb_extension';
About
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.