从临时表创建和删除之间获取数据
我通过添加临时表优化了 SQLite 脚本之一的性能,现在它看起来像这样:
create temp table temp.cache as select * from (...);
--- Complex query.
select * from (...);
drop table temp.cache;
这个解决方案的问题是我不再可以使用 Pandas 的 pd.read_sql_query
因为它不不返回任何结果并抛出异常,表示我只能执行一条语句。
您认为更好的解决方案是什么?我可以想到两个:
- A计划:无论如何都需要一些技巧来提取数据或
- 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:
- Plan-A: There is some trick to extract the data anyway or
- Plan-B: I need to call python's SQLite
execute
function before and after using Pandas to handle the temporary table.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论