> ## Documentation Index
> Fetch the complete documentation index at: https://docs.powerdrill.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Advanced Analytics

> Gives full play to the value of your data

export const community_0 = undefined

## Introduction

Are you finding yourself overwhelmed with raw data, struggling to discover the insights you need? Are your decisions based more on instinct rather than proves? Your solution is right here -- Powerdrill launches its new feature **Advanced Analytics**.

Advanced Analytics can generate visualizations such as charts and maps after analyzing raw data. With Advanced Analytics, all you need to do is to "tell" Advanced Analytics what you want in natural language and let it uncover the trends and patterns in your data.

We are excited to announce our extension on this feature -- SQL Advanced Analytics. This powerful new tool allows you to seamlessly integrate your SQL databases as data sources. Once connected, Powerdrill empowers you to delve into your data with the full suite of SQL commands, unlocking sophisticated analytical possibilities.

***

## How to use general Advanced Analytics

1. Sign in to [Powerdrill](https://powerdrill.ai).

2. Select **Advanced Analytics** and select the files you want to analyze.

   Only CSV, TSV, and Excel files are supported. Up to 10 files can be uploaded at a time.

3. Chat with Powerdrill to start your conversation over your dataset.

If you just want to see the effect of Advanced Analytics before uploading your own data, you can try our demo to take a glimpse.

***

## How to use SQL Advanced Analytics

To use SQL Advanced Analytics, you must first connect your SQL databases to Powerdrill. Currently, Powerdrill supports two types of SQL databases: MySQL and PostgreSQL.

<Tip>At Powerdrill, we prioritize the security of your data and privacy above all else. We have implemented robust security measures to ensure that your keys and passwords are never accessed or stored by our system.</Tip>

1. Sign in to [Powerdrill](https://powerdrill.ai).

2. In the left sidebar, select **Datasets**.

3. On the page that is displayed, click **+ Dataset** in the upper-right corner.

4. On the **Create Dataset** page, click the **SQL Databases** tab.

   If this is your first time using this feature, the platform will prompt you to specify a user with read-only access to your database. For details about how to create a user with read-only privileges on the database, see [Set user privileges to read-only](#set-user-privileges-to-read-only).

5. Select your SQL database type.

   * For PostgreSQL-compatible databases, select **PostgreSQL**.

   * For MySQL-compatible databases, select **MySQL**.

6. Configure credentials.

   * If you choose the `General` form, you need to specify the hostname, port, and name of the database to connect.

   * If you choose the `Advanced` form, fill in the domain name of the database to connect to complete the URL.

7. Configure authentication information, including the username and password used to connect to the database.

8. If the database is configured with IP allowlists or blocklists, ensure the IP addresses provided on the page are in the allowlists.

9. Click **Test Connection**. If the connection is successful, click **Finish**.

Now, you can ask questions about anything you want to know from your database.

### Set user privileges to read-only

The detailed procedure varies with your database type:

<Tabs>
  <Tab title="PostgreSQL databases">
    1. Connect to your PostgreSQL database as a superuser or a user with the necessary privileges to create roles and assign permissions.

       For example, run the following command in the `psql` CLI:

       ```bash theme={null}
       psql -U postgres
       ```

       Replace `postgres` with your superuser or administrative username.

    2. Run `CREATE ROLE` to create a role.

       ```sql theme={null}
       CREATE ROLE readonly_user WITH LOGIN PASSWORD 'password';
       ```

       Replace `readonly_user` with the desired username and `password` with a strong password. Alternatively, you can run `CREATE USER` as a shortcut for `CREATE ROLE ... WITH LOGIN`.

    3. Grant the `CONNECT` privilege on the database to the user.

       ```sql theme={null}
       GRANT CONNECT ON DATABASE <database_name> TO readonly_user;
       ```

    4. Grant the `USAGE` privilege on the schema where your data resides.

       ```sql theme={null}
       GRANT USAGE ON SCHEMA <schema_name> TO readonly_user;
       ```

    5. Grant the `SELECT` privilege on the tables in the schema.

       ```sql theme={null}
       GRANT SELECT ON ALL TABLES IN SCHEMA <schema_name> TO readonly_user;
       ```

    6. Set default privileges to allow `readonly_user` has the `SELECT` privilege on tables future created in the schema.

       ```sql theme={null}
       ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name> GRANT SELECT ON TABLES TO readonly_user;
       ```

    7. Check whether the user privileges are configured as expected in `psql`:

       ```bash theme={null}
       psql -U readonly_user -d database_name
       ```
  </Tab>

  <Tab title="MySQL databases">
    1. Use a MySQL CLI to connect to your MySQL server as the root user or another user with sufficient privileges to create new users and grant permissions.

       Following uses the `root` user and the `mysql` CLI as an example.

       ```bash theme={null}
       mysql -u root -p
       ```

    2. Enter the password as prompted.

    3. Create a user and set a password for the user.

       ```sql theme={null}
       CREATE USER 'readonly_user'@'localhost' IDENTIFIED BY '<password>';
       ```

           <Tip>
             * `readonly_user` is an example only. Replace it as needed.
             * If you want to allow the user to connect from any host, replace `localhost` with `%`.
           </Tip>

    4. Grant the `SELECT` privilege on all tables in the database to the `readonly_user` user.

       ```sql theme={null}
       GRANT SELECT ON <database_name>.* TO 'readonly_user'@'localhost';
       ```

    5. Make the privileges take effect.

       ```sql theme={null}
       FLUSH PRIVILEGES;
       ```

    6. Check whether the user privileges are configured as expected in `mysql`:

       ```sql theme={null}
       mysql -u readonly_user -p
       ```
  </Tab>
</Tabs>

***

## Need more help?

<CardGroup cols={2}>
  <Card title="Post to our help community" icon="discord" href="https://discord.com/invite/ZsyyD5ysRC">
    Get answers from our {community_0} members
  </Card>

  <Card title="Contact us" icon="envelope" href="mailto:service@powerdrill.ai">
    Tell us more and we'll help you out
  </Card>
</CardGroup>
