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 statement:

    CREATE DATABASE IF NOT EXISTS test;
  2. Create tables in the test database for testing basic and advanced operations with CREATE TABLE statements:

    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 statement:

  2. Ensure that the user account has privileges to access the tables with the GRANT statement:

This page is: Copyright © 2025 MariaDB. All rights reserved.

Last updated

Was this helpful?