Guest User

Untitled

a guest
May 29th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import pandas as pd
  2. import mysql.connector as sql
  3. import db_config as config
  4.  
  5. # Functions
  6. def mysql_con(host, database, user, password):
  7. return sql.connect(host=host, database=database, user=user, password=password)
  8.  
  9. # Credentials
  10. credentials_dict = {'host': config.host, 'database': 'database_name', 'user': config.user, 'password': config.password}
  11.  
  12. # Read
  13. with open('my_query.sql', 'r') as f:
  14. df = pd.read_sql(f.read(), con=mysql_con(**credentials_dict))
Add Comment
Please, Sign In to add comment