Connect DBeaver to MaxCompute

更新时间:
复制 MD 格式

Use the DBeaver database management tool to access MaxCompute projects and manage data. This topic describes how to connect to a project with the MaxCompute JDBC driver.

Background information

DBeaver is a free, multi-platform database tool for developers, database administrators, analysts, and anyone who works with databases. For more information, see DBeaver.

Prerequisites

Before you begin, ensure you have the following:

  • You have created a MaxCompute project.

    For more information, see Create a MaxCompute project.

  • An AccessKey pair (an AccessKey ID and an AccessKey Secret) with permissions to access your MaxCompute project.

    For more information, see Create an AccessKey pair.

  • You have downloaded the jar-with-dependencies JAR package, which contains all dependencies.

    You can click odps-jdbc-3.9.0.jar to download it, or obtain the latest version of the MaxCompute JAR package from GitHub or the Maven repository. The examples in this topic use v3.9.0 of the MaxCompute JDBC driver.

  • You have downloaded and installed DBeaver.

    For more information about the installation, see Install. The examples in this topic use DBeaver Community Edition 24.3.1.

Step 1: Connect DBeaver to MaxCompute

  1. Start DBeaver.

  2. Select the database type to connect to.

    In the top menu bar, click the 新建 new connection icon. In the Select your database dialog box, select SQL > SQLite, and then click Next. The Generic JDBC Connection Settings dialog box opens.

  3. Edit the driver settings.

    1. On the Main tab of the Generic JDBC Connection Settings dialog box, click Edit Driver Settings.

    2. Set the class name and URL template.

      In the Edit Driver 'SQLite' dialog box, on the Settings tab, set Class Name to com.aliyun.odps.jdbc.OdpsDriver and URL Template to jdbc:odps:{file}.

    3. Add the JDBC driver JAR package.

      On the Libraries tab of the Edit Driver 'SQLite' dialog box, click Add File to add the MaxCompute JDBC driver JAR package odps-jdbc-3.9.0-jar-with-dependencies.jar to the driver library.

    4. Click OK.

  4. Enter the JDBC URL.

    On the Main tab of the Generic JDBC Connection Settings dialog box, configure the JDBC URL.

    Parameter

    Description

    Connection Method

    Select URL.

    JDBC URL

    The URL for connecting to the MaxCompute project.

    • Example: jdbc:odps:https://service.cn-hangzhou.maxcompute.aliyun.com/api?project=test&accessId=xx&accessKey=xx.

    • Format: jdbc:odps:<maxCompute_endpoint>?project=<maxCompute_project_name>&accessId=<accessId>&accessKey=<accessKey>[&interactiveMode={true|false}]. Do not include the angle brackets (<>) in the URL.

      • <maxCompute_endpoint>: Required. The endpoint of the region where your MaxCompute project is located. For more information, see Endpoints.

      • <maxCompute_project_name>: Required. The name of the MaxCompute project to connect to.

      • accessId: Required. The AccessKey ID with permissions to access the MaxCompute project. You can obtain your AccessKey ID from the AccessKey Management page.

      • accessKey: Required. The AccessKey Secret that corresponds to the AccessKey ID.

      • interactiveMode: Optional. Specifies whether to enable the query acceleration feature.

        To enable query acceleration, append &interactiveMode=true to the URL. For more information about this feature, see Query acceleration.

  5. Click Test Connection. A successful connection is indicated by a Connected status in the Connection Test dialog box. Click OK to close this dialog, and then click Finish to complete the setup.

Step 2: Query and analyze data

After you connect DBeaver to MaxCompute, the new connection appears in the navigation pane on the left. You can use SQL to manage your MaxCompute project. The following sections describe common operations. For a complete list of features, see the DBeaver documentation.

  • View all tables

    You can view information about all tables under the created MaxCompute connection.

    In the Database Navigator pane on the left, expand the MaxCompute connection node, expand the database name, expand default, and then expand Tables to display the list of tables. You can also enter a keyword in the search box at the top to filter tables by name.

  • View table schema

    Under the MaxCompute connection, right-click a table and select View Table.

    For example, the sale_detail table has the following five columns: shop_name (STRING), customer_id (STRING), total_price (DOUBLE), sale_date (STRING), and region (STRING).

  • View table data

    • Under the MaxCompute connection, click SQL Editor > New SQL Editor. In the editor, enter and run an SQL query for the target table to view its data.

      For example, enter the query SELECT * FROM pyodps_ml_100k_lens;.

    • If the schema syntax switch is not enabled for your project, you can also view data by right-clicking the target table under the MaxCompute connection, selecting View Table, and then clicking the Data tab. For more information, see Schema Syntax Switch.