import pymysql
import datetime
import json
import redis
import pandas as pd
from sqlalchemy import create_engine


def get_mysql_data(host,port,user,passwd,db,sql):
    db = pymysql.connect(host=host, port=port, user=user, passwd=passwd,db=db)
    cursor = db.cursor()
    cursor.execute(sql)
    result = cursor.fetchall()
    db.close()
    return result


def get_user():
    sql = "select user_id,phone,name,city_id,channel,auth_type from user"
    df = pd.DataFrame(list(get_mysql_data(host,port,user,passwd,db,sql)))
    print(df.head(6))


if __name__ == "__main__":
    host = "172.16.30.141"
    port = 3306
    user = "work"
    passwd = "BJQaT9VzDcuPBqkd"
    db = "zhengxing"
    get_user()











