Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

python mysql query to dataframe

from sqlalchemy import create_engine
import pymysql

db_connection_str = 'mysql+pymysql://mysql_user:mysql_password@mysql_host/mysql_db'
db_connection = create_engine(db_connection_str)

df = pd.read_sql('SELECT * FROM table_name', con=db_connection)

# This works with "mysql.connector" as well
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #mysql #query #dataframe
ADD COMMENT
Topic
Name
9+7 =