Connect to the docker container (or Mysql server) with python
install python driver mysql-connector-python-rf with pip(pip3)
pip install mysql-connector-python-rf
connect to database
# import python packgeimportmysql.connector# connect to databaseconnection=mysql.connector.connect(user='root', password='root',
host='127.0.0.1',
database='ganjoor',
port='33699')
# close connection after workconnection.close()
Using Pandas: Get database as Pandas DataFrame
# if pandas is not installed on your machine , check pandas installationimportpandasaspd# use pd.read_sql(SQL, connection)# sample for reading all categories into one Pandas DataFramecategories_df=pd.read_sql("select * from categories", connection)