import pandas as pd
from sqlalchemy import create_engine
engine = create_engine("mysql+pymysql://{}:{}@{}:{}/{}".format('root', '123456', '127.0.0.1', '3306', 'account_drds'))
sql_query = 'select uid,app_id,uuid from device_base where uuid IS NOT NULL;'
df_read = pd.read_sql_query(sql_query, engine)
df.to_csv(f'/hdd/users/faker/uid.csv', index=False,
encoding='utf_8_sig')
如果密码有特殊字符比如@ 可以进行以下处理
from urllib import parse
connstr = "mysql+pymysql://root:%s@127.0.0.1:3306/account_drds" % parse.quote_plus(
'root@123456')
engine = create_engine(connstr, echo=True)
|