使用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
相关产品推荐
相关产品推荐

