Table of Contents

About

This howto shows you how to:

Steps

Docker Installation

howto docker services are an easy way to start locally a database instance.

Because howto services are docker services, you should have docker installed on your computer.

Check the service

By default, the user configuration vault is created with the howto docker services.

You can check if the mysql service is present and see its attributes with:

tabul service info mysql
Information about the service (mysql)
Attribute     Value                                                      Description
-----------   --------------------------------------------------------   --------------------------
COMMAND                                                                  The command
ENVIRONMENT   {MYSQL_DATABASE=howto, MYSQL_ROOT_PASSWORD=my-secret-pw}   The environment attributes
IMAGE         mysql:5.7.37                                               The image
IS_STARTED    false                                                      The status of the service
NAME          mysql                                                      The name of the service
ORIGIN        CONF                                                       The origin of the system
PORTS         3306:3306                                                  The ports
TYPE          docker                                                     The type of the system
VOLUMES                                                                  The volumes

tabul data print --type text .tabul/.tabul.yml@home | yq '.spec.services.mysql'
environment:
  MYSQL_DATABASE: howto
  MYSQL_ROOT_PASSWORD: my-secret-pw
image: mysql:5.7.37
ports:
  - 3306:3306
type: docker

If the service is not present, move or delete your user configuration vault file

Start the mysql service

To start the docker service, you can use

This service is based on the Official MySql Docker image.

tabul service start mysql
1 service was started
Name    Type
-----   ------
mysql   docker

You can use start the local database with the following Bash command :

docker run \
    -e MYSQL_DATABASE=howto \
    -e MYSQL_ROOT_PASSWORD=my-secret-pw \
    -p 3306:3306 \
    -d \
    --name mysql \
    mysql:5.7.37
docker run ^
    -e MYSQL_DATABASE=howto ^
    -e MYSQL_ROOT_PASSWORD=my-secret-pw ^
    -p 3306:3306 ^
    -d ^
    --name mysql ^
    mysql:5.7.37

Check that you can ping/connect to the service with the connection

tabul connection ping mysql
The connection (mysql) has been pinged successfully

Connection Info

By default, the user configuration vault is created with the howto docker services.

You can check the service with the tabul service info command

tabul connection info mysql
Information about the connection (mysql)
Attribute                    Value                               Description
--------------------------   ---------------------------------   --------------------------------------------------------------------
BOOLEAN_DATA_TYPE            Native                              Boolean data type used to store boolean values
BUILDER_CACHE_ENABLED        true                                Enable or disable the builder cache
CHAR_DEFAULT_PRECISION       1                                   Default CHAR precision
COMMENT                      The default mysql data store        A connection description
DATABASE_MAJOR_VERSION                                           The major version number of the database
DATABASE_MINOR_VERSION                                           The minor version number of the database
DATABASE_PRODUCT_NAME                                            The name of the database
DATABASE_PRODUCT_VERSION                                         The version of the database
DATE_DATA_TYPE               NATIVE                              Date data type used to store date values
DRIVER                       com.mysql.cj.jdbc.Driver            The jdbc driver class
DRIVER_NAME                                                      The driver name
DRIVER_VERSION                                                   The driver version
HOST                                                             Host Server
JDBC_MAJOR_VERSION                                               The major version number of JDBC
JDBC_MINOR_VERSION                                               The minor version number of JDBC
LOGIN_STATEMENTS                                                 Statements that runs after a connection has been established
MAX_CONCURRENT_THREAD                                            The maximum number of threads that can be created against the system
MAX_NAME_IN_PATH                                                 The maximum number of names in a path
NAME                         mysql                               The name of the connection
NAME_QUOTING_DISABLED_CASE   UPPERCASE                           The case to apply when quoting is disabled
NAME_QUOTING_ENABLED         true                                Enable quoting of names
NATIVES                                                          Native Driver attributes (jdbc properties, ...)
NCHAR_DEFAULT_PRECISION      1                                   Default NCHAR precision
NVARCHAR_DEFAULT_PRECISION   0                                   Default NVARCHAR precision
ORIGIN                       CONF                                The origin of the connection
PASSWORD                     my-secret-pw                        The user password
PORT                         3306                                Host Port
SUPPORT_BATCH_UPDATES                                            If the system supports batch SQL updates
SUPPORT_NAMED_PARAMETERS                                         If the system supports named parameters in the SQL statement
TIMESTAMP_DATA_TYPE          NATIVE                              Timestamp data type used to store timestamp values
TIME_DATA_TYPE               NATIVE                              Time format data type to store time values
URI                          jdbc:mysql://localhost:3306/howto   The uri of the connection
USER                         root                                The user name
VARCHAR_DEFAULT_PRECISION    2000                                Default VARCHAR precision
WORKING_PATH                 howto.                              The working path (Schema for database, directory for file system)

You can also check the connection attributes with the configuration vault

tabul data print --type text .tabul/.tabul.yml@home | yq '.spec.connections.mysql'
comment: The default mysql data store
driver: com.mysql.cj.jdbc.Driver
password: my-secret-pw
uri: jdbc:mysql://localhost:3306/howto
user: root
varchar-default-precision: 2000

If the connection is not present, move or delete your user configuration vault file

Use the mysql connection

You then can use the @mysql connection in place of any other connection

Example:

  • replacing the @sqlite connection by the @mysql
# with sqlite
# tabul data upsert characters.csv@howto @sqlite
# with mysql
tabul data upsert characters.csv@howto @mysql
# with sqlite
# tabul data list  *@sqlite
# with mysql
tabul data list  *@mysql
path         media_type
----------   ----------
characters   table

In particularly, you can follow:

Data Generator - How to generate a date dimension ?

A date dimension is a typical case for data generation and this article shows you how to generate it.
How to create a SQL View with a SELECT query

This howto shows you how to create sql views with select query stored in SQL file We are going to use the tpcds query_11.sql to create this view. With the tabul create command, to create view...
How to create a SQL view with a CREATE statement file

This Howto will show you how to create a SQL View with a SQL file that contains a CREATE SQL statement with the Tabul table create command. You should have Tabulify installed on your computer: ...
How to diff a SQL table ?

This howto show you how to perform diff operation between 2 SQL Tables with the data diff command. In this step, we load the csv resources that we want to compare into sqlite Load the original...
SQLite - How to fill a table with a resource data generator?

This how-to will show you how to define the generation of data via a data definition file and load it into a table via the tabul data fill operation.
SQLite - How to fill a table with auto generated data

This how-to will show you how to fill a table with auto-generated data and the Tabul fill action.
Sql Table

This How-to section is specific to the SQL Table
Tabul - How to create a table from the definition of another table

This Howto will show you how to copy the data definition of a SQL table from another SQL table
Tabul - How to list SQL Tables

This howto will show you how to list SQL Tables
Tabul - How to load a CSV file into a SQL table

How to upload a CSV file into a SQL table in two steps

Stop the mysql service

Once, you don't need the mysql service, you can stop it:

tabul service stop mysql
1 service was stopped
Name    Type
-----   ------
mysql   docker

You can also stop it with Docker

docker stop mysql