This project will show how JSON data type works in MySQL 8. We will create a database using percona-server:8.0 and then we will create the tables using Python with sqlalchemy and finally insert some data in the database.
We are working with Docker compose. if you want to turn off the services use this command:
docker compose up
# Or add "-d" to run the process in the background
docker compose ps -d
This command will start two services, one is the db which uses the image of percona-server:8.0 and the second service is called "api" which is a Python application with a Dockerfile. It wil create tables and insert some data in the database using sqlalchemy.
If you wanna see all the services:
docker compose ps
If you wanna turn down your services:
docker compose down
Checking the data in the database
You can enter into the container and execute commands to inspect the database
docker exec db /bin/bash
show databases;
use library;
show tables;
select * from book;
describe book;
Or you you inspect the database from outside the container
docker exec -i db mysql -uroot -proot <<< "use library;show tables;select * from book;describe book;"
Note This projects is open source feel free to send feedbacks or suggestions