Cube Logo0.33.23

Query data

In this step, you will learn how to query your data using the data models you created in the previous step. Cube Cloud provides several ways to query your data, and we'll go over them here.

The Developer Playground is a web-based tool that allows you to query your data without connecting any tools or writing any code. It's a fastest way to explore your data.

Navigate to the Playground page in Cube Cloud:

Cube Cloud Deployment Developer Playground Screen

Next, you will select the measures and dimensions you want to query, and then run the query. Let's do this for the orders cube you generated in the previous step.

Click + Measure to display the available measures and add orders.count, then click Run:

Cube Cloud Deployment Developer Playground Screen with a selected measure

Next, click + Dimension for available dimensions, add orders.status, and then click Run again:

Cube Cloud Deployment Developer Playground Screen with selected measures and dimensions

Please feel free to experiment: select other measures or dimensions, pick a granularity for the time dimension instead of w/o grouping, or choose another chart type instead of Table.

From the deployment's Overview page, you can copy the GraphQL API URL for the deployment:

Cube Cloud Deployment Overview Screen

To see an example of how to query the GraphQL API using curl, click How to connect your application:

Cube Cloud Deployment Screen with How to connect your application over GraphQL dialog open

Cube Cloud Deployment Overview Screen

To see an example of how to query the REST API using curl, click How to connect your application:

Cube Cloud Deployment Screen with How to connect your application over REST dialog open

First, navigate to the Settings page and enable the SQL API.

Then, on the Overview page, click How to connect, which will open instructions on connecting different tools to the SQL API. You should see a screen with your connection credentials:

We can test it by running the provided psql command:

PGPASSWORD=c9fba08a9b41f69f698b00134587d325 \
  psql -h fierce-bear.sql.aws-eu-central-1.cubecloudapp.dev \
  -p 5432 \
  -U cube fierce-bear

psql (14.5, server 14.2 (Cube SQL))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

fierce-bear=> SELECT COUNT(*) FROM orders;
 COUNT(UInt8(1))
-----------------
           10000
(1 row)

Since the SQL API is Postgres-compatible, please make sure to select Postgres as the database type when connecting from BI tools.

Now that we've seen how to use Cube's APIs, let's take a look at how to add pre-aggregations to speed up your queries.

Did you find this page useful?