# Is it possible to use CrateDB with a PostgreSQL database by using Foreign Data Wrapper?

**URL:** https://community.cratedb.com/t/is-it-possible-to-use-cratedb-with-a-postgresql-database-by-using-foreign-data-wrapper/813
**Category:** CrateDB
**Created:** [September 17, 2021, 3:09pm UTC](https://community.cratedb.com/t/is-it-possible-to-use-cratedb-with-a-postgresql-database-by-using-foreign-data-wrapper/813 "2021-09-17T15:09:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Emre\_Sevinc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/emre_sevinc/32/375_2.png) [@Emre\_Sevinc](https://community.cratedb.com/u/Emre_Sevinc)
#### Post date: [September 17, 2021, 3:09pm UTC](https://community.cratedb.com/t/is-it-possible-to-use-cratedb-with-a-postgresql-database-by-using-foreign-data-wrapper/813/1 "2021-09-17T15:09:57Z")

</div>

Is it possible to use CrateDB from within a PostgreSQL database by using **Foreign Data Wrapper**? Normally PostgreSQL allows to connect to some other databases by creating foreign data wrappers, as described in:

- [PostgreSQL: Documentation: 13: 5.12.&nbsp;Foreign Data](https://www.postgresql.org/docs/13/ddl-foreign-data.html)
- [PostgreSQL: Documentation: 13: F.33.&nbsp;postgres\_fdw](https://www.postgresql.org/docs/13/postgres-fdw.html)

(Assuming this is possible) Do you have any suggestions/recommendations if I want to query CrateDB tables from a PostgreSQL database?

---

<div class="post-metadata">

### Author: ![proddata](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/proddata/32/1379_2.png) [@proddata](https://community.cratedb.com/u/proddata)
#### Post date: [September 17, 2021, 3:30pm UTC](https://community.cratedb.com/t/is-it-possible-to-use-cratedb-with-a-postgresql-database-by-using-foreign-data-wrapper/813/2 "2021-09-17T15:30:57Z")

</div>

Currently this is unfortunately not supported.

We have tested connecting from PG to CrateDB using FDW, however it seems like for using postgresql\_fdw we miss Cursor support, which might be integrated with 4.8 (but still with a big question mark) also see [Add DECLARE CURSOR support · Issue #10212 · crate/crate · GitHub](https://github.com/crate/crate/issues/10212)

With using the more generic odbc\_fdw there are currently problems with passing down query parameters resulting in PG trying to load complete tables from CrateDB

—

We are also investigating the other direction (i.e. allowing querying a pg instance from within CrateDB, but no concrete plans for that yet.

---

<div class="post-metadata">

### Author: ![hernanc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/hernanc/32/676_2.png) [@hernanc](https://community.cratedb.com/u/hernanc)
#### Post date: [March 21, 2023, 3:46pm UTC](https://community.cratedb.com/t/is-it-possible-to-use-cratedb-with-a-postgresql-database-by-using-foreign-data-wrapper/813/3 "2023-03-21T15:46:56Z")

</div>

Hi,  
Just a quick update to mention that since CrateDB added support for `DECLARE CURSOR` this is now working but there are currently some limitations depending on the queries and the version of PostgreSQL, see [CrateDB/postgres\_fdw/LIMIT parameter](https://community.cratedb.com/t/cratedb-postgres-fdw-limit-parameter/1420) for details.
