---
title: "Database driver basics"
description: "What a Metabase driver does and how to package one as a plugin, with an example module you can copy."
url: "https://www.metabase.com/docs/latest/developers-guide/drivers/basics"
version: "65"
---

> For the complete documentation index, see [llms.txt](https://www.metabase.com/docs/llms.txt).

# Database driver basics

A Metabase driver:

- **Provides Metabase with basic information for the database** such as the database's capabilities, connection properties, and so on.
- **Provides Metabase with information about the schema of the database** -- the tables (or equivalent), the fields in those tables, the foreign key relationships (for databases that support foreign keys).
  - This functionality is used by the Metabase _sync process_ and stored in the application database.
  - The stored information is used in the visual Query Builder and other places to show users what tables/columns/etc. are available
- **Compiles our in-house query language, [MBQL](https://github.com/metabase/metabase/wiki/Query-Language-'98), into native queries.**
  - MBQL queries are generated by the visual query builder.
  - The Metabase **query processor\*** converts MBQL queries to native queries
- **Executes native queries and returns results**.

## Write your driver as a module and package it as a plugin

Metabase drivers are organized into modules and packaged as plugins. Modules are the source code; plugins are the JARs built from that source code.

A Metabase plugin is a JAR file that contains the compiled class files and a Metabase [plugin manifest](https://www.metabase.com/docs/latest/developers-guide/drivers/plugins.md) that lists details about the driver. In most cases, plugins are lazily loaded, which means that Metabase won't initialize the drivers until it connects to a database that would use the driver.

For Metabase to use your driver, all you need to do is put the driver JAR you built into the `/plugin` directory, which you'll find in the same directory where you run your metabase.jar. Something like this:

```
/Users/cam/metabase/metabase.jar
/Users/cam/metabase/plugins/my-plugin.jar
```

You can change the plugin directory by setting the [environment variable][env-var] `MB_PLUGINS_DIR`.

## Remove a driver

To remove a driver module from Metabase:

1. Delete the driver's folder from `modules/drivers`.
2. Delete the driver's dependency entry from `modules/drivers/deps.edn`.

You can't remove the Postgres, H2, or MySQL drivers, because Metabase needs them for application databases.

## Example module directory

Let's take a high-level look at how a driver module is laid out, using the [SQLite driver](https://github.com/metabase/metabase/blob/master/src/metabase/driver/sqlite.clj) as the example:

```
|-- deps.edn
|-- resources
|   `-- metabase-plugin.yaml
|-- src
|   `-- metabase
|       `-- driver
|           `-- sqlite.clj
`-- test
    `-- metabase
        |-- driver
        |   `-- sqlite_test.clj
        `-- test
            `-- data
                `-- sqlite.clj
```

There are three files to call out here:

### `deps.edn`

The `deps.edn` file specifies the driver's dependencies.

### `resources/metabase-plugin.yaml`

Your driver's [manifest](https://www.metabase.com/docs/latest/developers-guide/drivers/plugins.md#plugin-manifests) includes details about your driver.

### `src/metabase/driver/sqlite.clj`

This is the core file for your driver. We'll talk more about it in [Implementing multimethods](https://www.metabase.com/docs/latest/developers-guide/drivers/multimethods.md).

## Next Up

We'll learn more about [plugin manifests](https://www.metabase.com/docs/latest/developers-guide/drivers/plugins.md).

[env-var]: https://www.metabase.com/docs/latest/configuring-metabase/environment-variables.md
