pandas 执行sql语句

dbconn=pymysql.connect(
                host="rm-.mysql.rds.aliyuncs.com",
                database="nde",
                user="linr",
                password="deai$",
                port=3306,
                charset=‘utf8‘
                )

uids = [‘eTRxekVAYcDPX3BSvzS4‘,‘gyNZm5wAjFXPC2Gbc8Sd‘]
sql_data = """
    SELECT *
    FROM orders_order o
    INNER JOIN orders_management m
    ON o.uid = m.order_id INNER JOIN users_userinfo u on o.creater_id = u.uid
    WHERE o.uid in %s ORDER BY o.create_time;
    """
if uids:
    params = tuple(uids)
    print(params)
    df = pd.read_sql(sql_data, dbconn, params=(params,))  # 注意:要加 逗号 , 否则元祖与括号只有一个
    
    print(df)

pandas 执行sql语句

上一篇:Redis源码解析:一个命令的执行过程


下一篇:adb简单命令