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

使用sqlalchemy-cockroachdb时IMPORT作业创建后莫名消失的问题求助

CockroachDB IMPORT作业通过SQLAlchemy执行后莫名消失的问题

环境与准备

  • 使用sqlalchemy-cockroachdb v1.4.3适配器,本地CockroachDB已安装PostGIS扩展
  • 启动本地文件服务器以提供待导入的SQL文件:
    python -m http.server 3003 -d /path/to/file
    
  • 数据库引擎配置代码:
    engine = create_engine(f"{DIALECT}://{USER}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}")
    print(engine.__repr__())
    
    引擎输出结果:

    'Engine(cockroachdb://postgres:***@localhost:26257/climate)'

  • postgres用户拥有climate数据库的管理员权限

执行的Python代码片段

with Session(engine) as e:
    job = e.execute("import pgdump('http://localhost:3003/climate.sql') with ignore_unsupported_statements, DETACHED")
    job_id = job.fetchone()[0]
    print(job_id)

    job_status = e.execute(f"with jobs as (show jobs) select job_id, status from jobs where job_id = {job_id};")
    print(job_status.fetchall())

    sleep(1)

    print(job_status.fetchall())

执行结果

790071968723927041
[(790071968723927041, 'running')]
[]

创建作业后首次查询能返回状态为running,但程序休眠1秒后再次查询,作业记录完全消失,既没有显示失败或完成状态,也没有抛出任何错误。

命令行执行对比

通过CockroachDB命令行执行相同的导入语句,可成功完成数据导入:

cockroach sql -e "import pgdump('http://localhost:3003/climate.sql') with ignore_unsupported_statements, DETACHED" -d climate --user postgres --insecure

疑问

为何通过SQLAlchemy执行IMPORT作业后,作业仅1秒就莫名消失且无任何错误提示?


内容的提问来源于stack exchange,提问作者David den Uyl

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 14:48:15