You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

服务器端执行Pandas read_sql时报AttributeError问题求助

服务器端执行Pandas read_sql时报AttributeError问题求助

我最近碰到个棘手的问题,本地跑Python脚本完全正常,但部署到服务器上执行时,偏偏卡在了pd.read_sql这一行报错(具体是AttributeError,不过暂时没法贴出完整错误栈)。先给大家看下出问题的代码片段:

def request_pickup(connections, request_id):
    env_path = connections.loc[0, 'm_drive']

    hip_directory = connections.loc[0, 'hip_directory']

    sys.path.append(env_path + '/global_info')

    from py_variables import sqlalchemy_cnx_string, ssl_args

    engine = sqlalchemy.create_engine(sqlalchemy_cnx_string,
                                      connect_args = ssl_args)

    pickup_info_query = (f'''
        SELECT
            fld40 as record_id,
            fld3 as client_name
        FROM rmf_tb.rfsocatalogrh
        WHERE fld40 = {request_id}''')

    pickup_info = pd.read_sql(pickup_info_query, engine)

    if len(pickup_info) != 1:
        sys.exit("Pickup Request Error")

再补充下具体的场景细节:

  • 本地设计器里运行整个工作流毫无问题,没有任何报错
  • 但把工作流放到服务器上执行时,就会在pd.read_sql这一行直接失败
  • 我们用的Python工具不需要额外配置,之前一直运行正常,这次突然出了状况

我的环境版本信息:

  • SQLAlchemy: 1.3.18
  • Pandas: 2.0.3

有没有大佬遇到过类似的情况?或者能给点排查方向?比如会不会是服务器端的依赖版本、数据库连接权限、或者路径相关的问题导致的?

备注:内容来源于stack exchange,提问作者Srikanth Sirikonda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 13:44:39