WebSQL

WebSQL is a DoubleCloud service that allows you to connect to your Managed ClickHouse® clusters from your browser tab. It provides a full-fledged SQL editor that you can use to view databases and execute SQL queries.

Using WebSQL provides you with the following benefits:

  • Code autocompletion and error highlighting: write queries effortlessly with the help of Visual Studio Code's IntelliSense.

  • Data awareness: the query editor can suggest column names as well as column aliases and table aliases.

  • Connect without modifying allowlists: you can connect to your Managed ClickHouse® cluster without having to add your current IP address to the allowlist and restart the cluster.

  • Saved queries and templates: save queries for later use and create templates to write queries faster.

Connect to a Managed ClickHouse® cluster

You can access WebSQL and connect to Managed ClickHouse® clusters from the DoubleCloud console. WebSQL can't connect to clusters deployed in private networks or clusters in certain states, such as Stopped.

To connect to a cluster:

  1. On the Clusters page in the console, select the ClickHouse® cluster you want to connect to.

  2. Click WebSQL at the top right:

    Screenshot of a ClickHouse® cluster page in the DoubleCloud console showing the WebSQL button

    Note

    If WebSQL doesn't have permissions to access the cluster, go to the Allowlist tab and enable access for Visualization and WebSQL under Access from DoubleCloud services.

  3. If you have admin access to the cluster, you'll be connected automatically using the admin user credentials. Otherwise, enter the credentials of a ClickHouse® user when prompted.

Execute a query

  1. After you've connected to a cluster, select a database in the connection manager on the left:

    Screenshot of WebSQL showing the connection manager

  2. Enter a query in the query editor and click Execute:

    Screenshot of WebSQL showing the query editor

  3. WebSQL shows the query result under the editor. You can export the result in the JSON, CSV, or TSV format.

    Note

    If the query result contains over 1000 rows, only the first 1000 rows are displayed.

View table details

  1. After you've connected to a cluster, select a database in the connection manager on the left.

  2. Find a table whose details you want to view and click Table overview.

    table-overview

Saved queries

You can save any query to access and use it later or make it a template.

Save a query

  1. In the query editor, click .

  2. Enter a query name.

  3. (Optional) If you want to reuse the saved query as a template, enable Add template and enter a name for the template.

  4. Review the query you're saving.

    Tip

    If you save the query as a template, you can use variables:

    SELECT $1 FROM bookings LIMIT $2
    
  5. Click Save.

Access saved queries

You can access saved queries in the Saved queries section in the left panel.

Use a template

To use a template, start typing template in the query editor and select a template from the suggestion list.

Predefined templates start with template_ and user templates start from userTemplate_.

Tip

To jump between variables in templates, use the Tab key.

Query history

WebSQL keeps history of queries executed in the current connection session.

To access query history, click on Query history in the left panel.

Tip

By default, WebSQL keeps history of queries, but not query results. You can enable saving successful query results in Settings General.

Configure WebSQL and query editor

To access query editor settings, at the bottom of the left panel click Settings Query editor.