# Using the Data Playground

You can test your models in Embeddable’s **Data Playground**.  Simply click the in-platform **Data Playground** tab on the left of the main platform screen:

Video: https://docs.embeddable.com/video/data-playground.mp4

 - **View as**: this allows you to test the row-level security by viewing the data as if you are different end-users ([learn more](https://docs.embeddable.com/data-modeling/row-level-security/security-filters#testing-your-security-filters)).
 - **Data model**: choose which data model you want to test ([defining data models](https://docs.embeddable.com/data-modeling/writing-data-models/defining-models)) 
 - **Columns**: choose which dimensions and measures you want to see (note that all dimensions and measures that are "reachable" from the chosen *data model* will be available here. i.e. any dimensions and measures from any model that can be reached via a join) ([dimensions and measures](https://docs.embeddable.com/data-modeling/writing-data-models/dimensions-and-measures))
 - **Models version**: this allows you to load previous versions of models ([pushing your models](https://docs.embeddable.com/data-modeling/pushing-models))
 - **Generated SQL**: once you click the "Run" button, the SQL that will be used to retrieve your chosen columns will be shown here.  This is very useful for debugging your models to understand if the SQL has been defined correctly for your database data.
 - **Results**: once you click the "Run" button, the SQL will be run against your database, and the results will be shown here (or an error message if your database has a problem running the generated SQL).

## Testing your local data models

The data playground (see above) can also be used to test [code models](https://docs.embeddable.com/data-modeling/getting-setup#defining-models-in-code) locally on your computer.  Access it by running:

```bash
npm run embeddable:dev
```
from your code repository.  This will spin up a "dev" workspace that uses your local models.

- The local workspace uses the same data connections as your online workspace.
- Simply click the Data Playground tab in the left sidebar. 
- You’ll then be able to test each element of your models, view the generated SQL, and inspect the results.  

You can also build dashboards in the "dev" workspace to test your local models on a dashboard. 

> If your models are in a [separate repo](https://docs.embeddable.com/data-modeling/getting-setup#2-storing-models-separately) to your components then, when running `embeddable:dev`, you'll have access to the components available in your online workspace.

   

## Testing using Cube's Data Playground

You can also use Cube's local Data Playground to test and debug your models.

> This relies on you having [Docker](https://www.docker.com/products/docker-desktop/) installed on your local machine.

### Create a `.env` file:  
   Ensure your `.env` file is in the same directory as `cube-playground.yml` ([this directory](https://github.com/embeddable-hq/vanilla-components/tree/main/src)).

### Populate the `.env` file: 

   Populate the `.env` file with the correct database credentials for your database as per the [Cube's documentation](https://cube.dev/docs/product/configuration/data-sources).

    ```env
    CUBEJS_DB_TYPE=postgres
    CUBEJS_DB_HOST=localhost
    CUBEJS_DB_NAME=your_database
    CUBEJS_DB_USER=your_username
    CUBEJS_DB_PASS=your_password
    ```

    You may need to add:
    ```env
    CUBEJS_DB_SSL=true
    ````

    You can also add set the **desired level of logging detail**, which can be useful for debugging and monitoring:
    ```env
    CUBEJS_DB_SSL=warn 
    ```
    **Possible values**:  
    `warn` *(default value)*: Logs warnings in addition to errors.  
    Example: Deprecation warnings or configuration issues. 

    `error`: Logs only critical errors that affect the application's functionality.  
    Example: Database connection issues or critical service failures.

    `info`: Logs general informational messages about the application's operations.  
    Example: Application startup, health checks, or key lifecycle events. 

    `trace`: Logs the most detailed information, primarily used for in-depth debugging.  
    Example: Internal function calls and exhaustive execution details.

### Run the Playground  
   Execute the following command to start Cube's data playground:
   ```bash
   npm run cube:playground
   ```

   You can also use docker compose:
   ```bash
   docker compose -f ./src/cube-playground.yml up
   ```

### Access the Playground 
   Open your browser and navigate to [localhost:4000](http://localhost:4000) to use Cube Playground.

### Still Need Help?

If you encounter any issues while testing your data models, feel free to reach out to our [**Slack community**](https://join.slack.com/t/embeddablecommunity/shared_invite/zt-20b4f6s10-gULqO6riqutJcbUi_FJmZA) or contact our support team for assistance.

---
Source: https://docs.embeddable.com/data-modeling/testing-models
