Connecting CrateDB through Postgrest or Hasura Graphql


Is there a possibility of integrating CrateDB with either PostgRest or Hasura Graphql.

Any hints or documents can be helpful.

I am new to cratedb … I just understood architecture of Cratedb.

Some insights on connecting CrateDb through PostgRest or Hasura Graphql will be helpful.

Thank you.


I don’t think we have official support or guides for those engines/APIs yet. But we happy if you could share your experiences.

Generally CrateDB exposes a Postgres compatible Interface on the postgres Port 5432. So you can connect to CrateDB pretty similiar as to a native Postgres database. If your are running CrateDB on your local machine you may use the user crate without password. If you are using a cloud instance, be sure to activate TLS/SSL in the API/engine and use your credentials to login.

Also CrateDB has an http-endpoint cratehost:4200/_sql that can be used to send SQL requests directly via http(s).

Hello @proddata ,

Has there been any change with this particular item?

I am trying to connect Hasura to CrateDB 5.0 and getting the following error on Hasura:

        "definition": "CrateDB",
        "reason": "Inconsistent object: postgres tx error",
        "name": "source CrateDB",
        "type": "source",
        "message": {
            "prepared": true,
            "error": {
                "exec_status": "FatalError",
                "hint": null,
                "message": "line 1:38: mismatched input 'READ' expecting {<EOF>, ';'}",
                "status_code": "XX000",
                "description": null
            "arguments": []

Hi @asavran

I think what you reported is actually a bug / wrong behaviour in CrateDB.
While CrateDB does not support transactions, it should just gracefully ignore provided BEGIN / START statements.

I created an issue in the crate/crate repository.

There already is a fix for this, which will be released with the next version of CrateDB that accepts transaction modes that are not comma separated as well:

However, be aware, that we don’t officially support Hasura and that I’d be careful especially with any DDL / DML queries.

In terms of GraphQL and CrateDB you might also want to look into Graphene (using crate-python and SQL Alchemy)

Thank you for the suggestions @proddata.