Setup for Examples
This page is part of MariaDB's Documentation.
The parent of this page is: MariaDB Connector/Python
Topics on this page:
Overview
The examples in this MariaDB Connector/Python documentation depend on a database test
and tables contacts
and accounts
.
Create the Schema
Create a
test
database if one does not exist with the statement:CREATE DATABASE IF NOT EXISTS test;
Create tables in the
test
database for testing basic and advanced operations with 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
Create a user account to test connectivity with the
statement:CREATE USER 'db_user'@'192.0.2.1' IDENTIFIED BY 'db_user_password';
Ensure that the user account has privileges to access the tables with the
statement: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';