HTTP & Auth for XTDB

If using XTDB from a non-supported language via HTTP, do you still have to have at least enough Clojure wrapping XTDB to support authentication?

Or can you do something like run the back end language and XTDB on the same server, and have them communicate over HTTP but over a port instead of a network request or something?

I’m sold on the benefits of XTDB but don’t yet know much Clojure, so was trying to figure out the bare minimum, but still safe / production worthy way to access XTDB. (I’d like to learn Clojure eventually.)

Hey @dave-mays assuming you are looking at v2 - we’re about to roll out the documentation (see psql docs by refset · Pull Request #3496 · xtdb/xtdb · GitHub) for Postgres wire-protocol compatibility, meaning you can connect to XT as if it were a Postgres database using standard Postgres driver (though the grammar and behaviour is far from identical).

Use of either the pgwire endpoint or HTTP endpoint can certainly work fine locally (i.e. securely, with ports that are unavailable outside of loopback) but you may find it simpler ultimately to not couple deployments/lifecycles of your app servers to the database server instances. If you need to get secure remote connections up and running across a network in the near future and feel XTDB can do more to assist, then please point to the kind of setup you are hoping to see (any comparable system you have in mind?).

Understanding or use of Clojure should not be required, we’re keen to make sure of that :slightly_smiling_face:

I was looking at V1, but if V2 is that close a Postgres driver sounds helpful.
Though do you only get the Datalog style queries from within HTTP or embedded Clojure? I imagine these would not be supported through a Postgres driver.

I was actually looking to try and connect from the Gleam language. Not sure if this package would meet the driver requirements, but appears to be the closest thing to a Postgres driver:
lpil/pgo: :elephant: Use PostgreSQL databases with PGO (github.com)

1 Like

Thanks for the link - Gleam looks pretty interesting! You’re right though in thinking that the Postgres-driver route is not focused on XTQL (Datalog-style queries) currently - SQL is the priority for the moment, see the response here also Wire protocol for XTQL - #3 by refset

Using v1 over HTTP (for Datalog) might work nicely but you would probably want to write an edn library for Gleam first.

Hey @refset ! This is indeed very interesting. I’m in a full-stack Node.js environment (SvelteKit) and recently been looking into XTDB. Looking forward to testing this without the Clojure dependency/requirement. Would Postgres driver compatibility eventually also mean that an ORM/query builder like Drizzle or Kysely also would work with XTDB, except for the very XT specific queries (which could just be done through the likes of sql`` anyways)?

Hey @andreas :wave:

Would Postgres driver compatibility eventually also mean that an ORM/query builder like Drizzle or Kysely also would work with XTDB, except for the very XT specific queries (which could just be done through the likes of sql`` anyways)?

That’s the plan, yes. Right now though there is some requirement to always specify parameter types and the node-postgres library doesn’t really allow for that, but we do have the (confusingly named) postgres library working, see this preview of a new docs page (PR) with an example of that: Postgres Drivers and Compatibility | XTDB

This approach potentially might already work with GitHub - kysely-org/kysely-postgres-js: Kysely dialect for PostgreSQL using the Postgres.js client. but we’ve not tried that yet - would love to hear feedback though if you do give it a go!

1 Like