---
metadata:
  - name: generator
    content: Diplodoc Platform v5.63.0
alternate:
  - en/operations/connection/create-ydb
  - ru/operations/connection/create-ydb
  - href: en/operations/connection/create-ydb.md
    type: text/markdown
    title: Markdown version
csp:
  - script-src:
      - https://mc.yandex.ru
    img-src:
      - https://mc.yandex.ru
    connect-src:
      - https://mc.yandex.ru
      - wss://mc.yandex.ru
    child-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-ancestors:
      - 'blob:'
      - https://mc.yandex.ru
canonical: en/operations/connection/create-ydb.html
title: How to create a Managed Service for YDB connection in DataLens On-premises
description: >-
  Follow this guide to create a connection to Managed Service for YDB in
  DataLens On-premises.
vcsPath: en/operations/connection/create-ydb.md
---

# Creating a connection to YDB from DataLens On-premises

{% note info %}


To write subqueries in datasets and queries in QL charts, use the [YQL syntax](https://ydb.tech/docs/en//yql/reference/syntax/).

{% endnote %}

To create a YDB connection:



1. Go to the [workbook](../../workbooks-collections/index.md) page or create a new one.
1. In the top-right corner, click **Create** → **Connection**.
1. Select the **YDB** connection.
1. Select the authentication type:

   {% list tabs group=auth-type %}

   - Anonymous {#anonymous}

     * **Host name**: Specify the path to the YDB host.
     * **Port**: Specify the YDB connection port. The default port is 2135.
     * **Path to database**: Specify the database name.

   - Password {#password}

     * **Host name**: Specify the path to the YDB host.
     * **Port**: Specify the YDB connection port. The default port is 2135.
     * **Path to database**: Specify the database name.
     * **Username**: Specify a username for the YDB connection.
     * **Password**: Specify a password for the user.

   - OAuth {#oauth}

     * **OAuth token**: Specify an OAuth token to use with YDB.
     * **Host name**: Specify the path to the YDB host.
     * **Port**: Specify the YDB connection port. The default port is 2135.
     * **Path to database**: Specify the database name.

   {% endlist %}

   * **Cache TTL in seconds**: Specify cache TTL or leave the default value. The recommended value is 300 seconds (5 minutes).
   * **Raw SQL level**: Enables you to use an ad-hoc SQL query to [generate a dataset](../../dataset/settings.md#sql-request-in-datatset).

1. Click **Create connection**.
1. Enter a name for the connection and click **Create**.


## Additional settings {#additional-settings}

You can specify additional connection settings under **Advanced connection settings**:

* **TLS**: Indicates whether TLS is required. When this option is enabled, the connection requires using SSL.
* **CA Certificate**: To upload a certificate, click **Attach file** and select the certificate file. When the certificate is uploaded, the field shows the file name.


{% cut "RESOURCE_EXHAUSTED error" %}

If the Managed Service for YDB quotas and limits are exceeded, you may get the `RESOURCE_EXHAUSTED` error message. To avoid the error, follow these recommendations:

* Reduce the query rate. To achieve this, you can use filters or specify only the required chart fields to limit the amount of data you get.
* Follow the recommendations for database [query optimization](../../concepts/optimization_recommendations.md).
* Use the DataLens [chart inspector](../../concepts/chart/inspector.md) to assess the data amount and upload time.
* Check the Managed Service for YDB monitoring charts for exceeded quotas and limits. If you need to, you may slightly increase the throughput capacity (request units) limit under **Limits**.

{% endcut %}
