Answers for "how to read mysql table in python"

1

how to read mysql table in python

import pandas as pd
import sqlalchemy

# make sure you have installed both mysql & pymysql

													# root:root is my username and password/default
engine = sqlalchemy.create_engine("mysql+pymysql://root:root@localhost/database name", pool_pre_ping=True)
# then specify the name of the table in the database
df = pd.read_sql_table('table name', engine)
print(df)
Posted by: Guest on March-08-2021
0

how to read mysql table in python

# for those who can't see all columns in the
# output when getting data from database

# just paste in the following code and that should be fixed
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', None)
Posted by: Guest on March-08-2021
0

python retrieves records after db select query

cursor.fetchall()
Posted by: Guest on June-09-2020

Code answers related to "how to read mysql table in python"

Python Answers by Framework

Browse Popular Code Answers by Language