从临时表创建和删除之间获取数据

发布于 2025-01-14 15:57:37 字数 469 浏览 3 评论 0原文

我通过添加临时表优化了 SQLite 脚本之一的性能,现在它看起来像这样:

create temp table temp.cache as select * from (...);

--- Complex query.
select * from (...);

drop table temp.cache;

这个解决方案的问题是我不再可以使用 Pandas 的 pd.read_sql_query 因为它不不返回任何结果并抛出异常,表示我只能执行一条语句。

您认为更好的解决方案是什么?我可以想到两个:

  1. A计划:无论如何都需要一些技巧来提取数据或
  2. B计划:我需要在使用Pandas处理临时表之前和之后调用python的SQLite execute函数。

I have optimized the peformance of one of my SQLite scripts by adding a temporary table so now it looks like this:

create temp table temp.cache as select * from (...);

--- Complex query.
select * from (...);

drop table temp.cache;

The issue with this solution is that I no longer can use Pandas' pd.read_sql_query because it doesn't return any result and throws an exception saying I'm allowed to execute only a single statement.

What would you say is the preferable solution? I can think of two:

  1. Plan-A: There is some trick to extract the data anyway or
  2. Plan-B: I need to call python's SQLite execute function before and after using Pandas to handle the temporary table.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文