/ganjoor-db

Ganjoor's MySQL Docker Instance + Data

Primary LanguageDockerfileMIT LicenseMIT

Ganjoor Database As SQL, Docker , CSV

Usage guid for Ganjoor database as Sql, Docker Image , Csv file

To download SQL file and Csv files check releases


For more information, please visit the API repo or the Project Roadmap.

Database Schema

Tables:

+---------------------+
| Tables_in_ganjoor   |
+---------------------+
| categories          |
| categoriesancestors |
| poems               |
| poets               |
| verses              |
+---------------------+

Database relations:

Database relation Schema as dbduigram

online version

Run docker with pulling from web

docker run -d  -p 33699:3306  aminsharifi/ganjoor-db

Create your own docker

  1. Clone Repo
git clone https://github.com/bigmpc/ganjoor-db
  1. cd to repo dir
cd ganjoor-db
  1. make docker image
docker build --tag=ganjoor-db .
  1. run docker image
docker run -d  -p 33699:3306  ganjoor-db

Connect to docker with mysql client

mysql -u root -p 'root' -h 127.0.0.1 -P 33699 -D ganjoor

Connect to the docker container (or Mysql server) with python

  1. install python driver mysql-connector-python-rf with pip(pip3)
pip install mysql-connector-python-rf
  1. connect to database
# import python packge
import mysql.connector

# connect to database
connection = mysql.connector.connect(user='root', password='root',
                              host='127.0.0.1',
                              database='ganjoor',
                             port='33699')

# close connection after work
connection.close()

Using Pandas: Get database as Pandas DataFrame

# if pandas is not installed on your machine , check pandas installation
import pandas as pd


# use pd.read_sql(SQL, connection)
# sample for reading all categories into one  Pandas DataFrame
categories_df = pd.read_sql("select * from categories", connection)