Query data

This page describes how to query data from QuestDB using different programming languages and tools. To query data in a running instance, there are three main methods that can be used:

Prerequisites#

QuestDB must be running and accessible, you can do so from Docker, the binaries or Homebrew for macOS users.

Postgres compatibility#

You can query data using the Postgres endpoint that QuestDB exposes. This is accessible via port 8812.

const { Client } = require("pg")
const start = async () => {
try {
const client = new Client({
database: "qdb",
host: "127.0.0.1",
password: "quest",
port: 8812,
user: "admin",
})
await client.connect()
const res = await client.query("SELECT x FROM long_sequence(5);")
console.log(res.rows)
await client.end()
} catch (e) {
console.log(e)
}
}
start()

REST API#

You can query data using the REST API, this will work with a very wide range of libraries and tools. The REST API is accessible on port 9000.

More information on the available endpoints alongside possible parameters and usage examples can be found on the REST API reference page.

curl -G \
--data-urlencode "query=SELECT x FROM long_sequence(5);" \
http://localhost:9000/exec

Web Console#

Details for inserting data with the Web Console is covered on the insert data page. To query data from the web console, SQL statements can be written in the code editor and executed by clicking RUN.

Listing tables and querying a table
SHOW TABLES;
SELECT * FROM my_table;
--Note that `SELECT * FROM` is optional
my_table;

Aside from the Code Editor, the Web Console includes a Visualization panel for viewing query results as tables or graphs and an Import tab for uploading datasets as CSV files. For more details on these components and general use of the console, see the Web Console reference page.