# Database guide

## Database providers

To connect to database servers you must configure a database provider. Just like with the [Cache](/guide/cache-guide.md) module, you can configure multiple providers to connect to multiple databases at the same time.

> Cherrycake is currently only compatible with MySQL and MariaDB servers.

Database providers are configured in the [Database configuration](/reference/core-modules/database.md#configuration) file `Database.config.php`.For example, if you want to connect to a MySQL database server, your Cache configuration file would look like this:

```php
<?php

namespace Cherrycake;

$DatabaseConfig = [
    "providers" => [
        "main" => [
            "providerClassName" => "DatabaseProviderMysql",
            "config" => [
                "host" => "localhost",
                "user" => "user",
                "password" => "password",
                "database" => "cherrycake",
                "charset" => "utf8mb4",
                "cacheProviderName" => "engine"
            ]
        ]
    ]
];
```

> Note we called our database provider `main`&#x20;

## Modules that depend on Database

Just like Cache, some other modules use Database for many purposes, for example: The [Session](/reference/core-modules/session.md) module uses a database connection to store information about sessions.

> That's why in the [Cherrycake Skeleton](/guide/getting-started/skeleton.md) boilerplate you'll find the `/install` directory containing some SQL scripts to create the tables some this modules need.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cherrycake.tin.cat/guide/database-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
