how to read mysql table in python

Solutions on MaxInterview for how to read mysql table in python by the best coders in the world

showing results for - "how to read mysql table in python"
Debora
05 Sep 2018
1# for those who can't see all columns in the
2# output when getting data from database
3
4# just paste in the following code and that should be fixed
5pd.set_option('display.max_rows', None)
6pd.set_option('display.max_columns', None)
7pd.set_option('display.width', None)
8pd.set_option('display.max_colwidth', None)
Lucia
12 Aug 2016
1import pandas as pd
2import sqlalchemy
3
4# make sure you have installed both mysql & pymysql
5
6													# root:root is my username and password/default
7engine = sqlalchemy.create_engine("mysql+pymysql://root:root@localhost/database name", pool_pre_ping=True)
8# then specify the name of the table in the database
9df = pd.read_sql_table('table name', engine)
10print(df)