在Perl的DBI填写占位符后,如何打印执行的SQL查询? [英] How can I print the SQL query executed after Perl's DBI fills in the placeholders?

查看:357
本文介绍了在Perl的DBI填写占位符后,如何打印执行的SQL查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Perl的DBI模块.我使用占位符准备一条语句,然后执行查询.

I'm using Perl's DBI module. I prepare a statement using placeholders, then execute the query.

是否可以在不手动转义参数并将其放入占位符的情况下打印出已执行的最终查询?

Is it possible to print out the final query that was executed without manually escaping the parameters and dropping them into the placeholders?

谢谢

推荐答案

请参见在DBI中进行跟踪.以下使用DBD::SQLite起作用,但会产生很多输出:

See Tracing in DBI. The following works using DBD::SQLite but produces a lot of output:

$dbh->trace($dbh->parse_trace_flags('SQL|1|test'));

输出:

<- prepare('SELECT ... FROM ... WHERE ... = ?')= DBI::st=HASH(0x21ee924) at booklet-excel.pl line 213

<- execute('Inhaler')= '0E0' at booklet-excel.pl line 215

等等等

您可以将自己的过滤器插入跟踪流仅保留prepare个.

这篇关于在Perl的DBI填写占位符后,如何打印执行的SQL查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆