PostgreSQL & PGWire
QuestDB supports the Postgres Wire Protocol (PGWire) for data-in.
For querying and data-out, QuestDB is compatible with PostgreSQL queries.
This means that you can use your favorite PostgreSQL client or driver with QuestDB.
For information querying and data-out, see the Querying & SQL Overview
note
The PostgreSQL storage model is fundamentally different than that of QuestDB.
As a result, some features that exists for Postgres do not exist in QuestDB.
#
Ingest examples- psql
- Python
- Java
- NodeJS
- Go
- Rust
note
If you using the QuestDB Cloud, your database requires TLS to connect. You can find host, port, and password configuration at https://cloud.questdb.com, on your instance "Connect" tab. To enable SSL from psql in the commands below, please follow this pattern:
psql -h {hostname} -p {port} -U admin "dbname=qdb sslmode=require" -c '{SQL_STATEMENT}'
Create the table:
Insert row:
Query back:
Note that you can also run psql
from Docker without installing the client
locally:
This example uses the pg
package which
allows for quickly building queries using Postgres wire protocol. Details on the
use of this package can be found on the
node-postgres documentation.
This example uses naive Date.now() * 1000
inserts for Timestamp types in
microsecond resolution. For accurate microsecond timestamps, the
process.hrtime.bigint()
call can be used.
This example uses the pgx driver and toolkit for PostgreSQL in Go. More details on the use of this toolkit can be found on the GitHub repository for pgx.
The following example shows how to use parameterized queries and prepared statements using the rust-postgres client.
For query examples, see Query & SQL Overview.
#
Query examplesFor full query details and examples, see the PostgreSQL section in the Query & SQL Overview.
#
Compatibility#
List of supported features- Querying (all types expect
BLOB
) - Prepared statements with bind parameters (check for specific libraries below)
INSERT
statements with bind parametersUPDATE
statements with bind parameters- DDL execution
- Batch inserts with
JDBC
- Plain authentication
#
List of supported connection propertiesName | Example | Description |
---|---|---|
database | qdb | Should be set to any value for example qdb , database name is ignored, QuestDB does not have database instance name |
user | admin | User name configured in pg.user or pg.readonly.user property in server.conf . Default value is admin |
password | quest | Password from pg.password or pg.readonly.password property in server.conf . Default value is quest |
options | -c statement_timeout=60000 | The only supported option is statement_timeout . It specifies maximum execution time in milliseconds for SELECT or UPDATE statement |
#
List of unsupported features- SSL
- Remote file upload (
COPY
fromstdin
) DELETE
statementsBLOB
transfer
#
Recommended third party toolsThe following list of third party tools includes drivers, clients or utility CLIs that our team has tested extensively. Picking an item from it will guarantee that your code will work with QuestDB.
We recognize that our community might value some features more than others. This is why we encourage you to open an issue on GitHub if you think we are missing something important for your workflow.
#
CLIsPSQL 12
#
Support for SELECT
, INSERT
, UPDATE
, CREATE
, DROP
, TRUNCATE
.