> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/connectors/mariadb-connector-python/setup-for-examples.md).

# Setup for Examples

The examples in this MariaDB Connector/Python documentation depend on a database `test` and tables `contacts` and `accounts`.

## Create the Schema

1. Create a `test` database if one does not exist with the [CREATE DATABASE](/docs/server/reference/sql-statements/data-definition/create/create-database.md) statement:

   ```sql
   CREATE DATABASE IF NOT EXISTS test;
   ```
2. Create tables in the `test` database for testing basic and advanced operations with [CREATE TABLE](/docs/server/server-usage/tables/create-table.md) statements:

   ```sql
   CREATE TABLE test.contacts (
      id INT PRIMARY KEY AUTO_INCREMENT,
      first_name VARCHAR(25),
      last_name VARCHAR(25),
      email VARCHAR(100)
   ) ENGINE=InnoDB;

   CREATE TABLE test.accounts (
      id INT PRIMARY KEY AUTO_INCREMENT,
      first_name VARCHAR(25),
      last_name VARCHAR(25),
      email VARCHAR(100),
      amount DECIMAL(15,2) CHECK (amount >= 0.0),
      UNIQUE (email)
   ) ENGINE=InnoDB;
   ```

## Create the User

1. Create a user account to test connectivity with the [CREATE USER](/docs/server/reference/sql-statements/account-management-sql-statements/create-user.md) statement:

   ```sql
   CREATE USER 'db_user'@'192.0.2.1'
      IDENTIFIED BY 'db_user_password';
   ```
2. Ensure that the user account has privileges to access the tables with the [GRANT](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md) statement:

   ```sql
   GRANT SELECT, INSERT, UPDATE, DELETE, DROP
      ON test.contacts
      TO 'db_user'@'192.0.2.1';

   GRANT SELECT, INSERT, UPDATE, DELETE, DROP
      ON test.accounts
      TO 'db_user'@'192.0.2.1';
   ```

<sub>*This page is: Copyright © 2025 MariaDB. All rights reserved.*</sub>

{% @marketo/form formId="4316" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://mariadb.com/docs/connectors/mariadb-connector-python/setup-for-examples.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
