如何在iPhone上记录SQLite查询

时间:2020-12-08 22:01:34

I'm doing an iPhone application, and I'm using SQLite.

我正在做一个iPhone应用程序,我正在使用SQLite。

The problem is that I had some issues with the query (I did bad binding) so, this is my question:

问题是我在查询中遇到了一些问题(我做错了绑定)所以,这是我的问题:

How can I log in my iPhone application the effective SQL query/statement with the bindings that SQLite receives?

如何使用SQLite接收的绑定在我的iPhone应用程序中登录有效的SQL查询/语句?

Thanks.

2 个解决方案

#1


Easiest way would be to create a wrapper to your call to sql functions and add log functionality to it.

最简单的方法是为sql函数调用创建一个包装器并为其添加日志功能。

I'm not sure the file written by the PRAGMA journal_mode is readable, but I couldnt use this pragma.

我不确定PRAGMA journal_mode写的文件是否可读,但我不能使用这个pragma。

You can also have a look at an excellent existing wrapper from Gus Mueller: fmdb

您还可以看看Gus Mueller的优秀现有包装器:fmdb

#2


I don't think this is possible.

我不认为这是可能的。

As far as I know, prepared statements aren't built into "full SQL" strings before they get to the database engine. The parameter values aren't escaped, quoted, and inserted into the SQL string only to be parsed and decoded in the next step: the values bypass the query parsing entirely and go straight into the data engine.

据我所知,准备好的语句在进入数据库引擎之前不会内置到“完整SQL”字符串中。参数值不会被转义,引用和插入到SQL字符串中,只能在下一步中进行解析和解码:这些值会绕过查询完全解析并直接进入数据引擎。

#1


Easiest way would be to create a wrapper to your call to sql functions and add log functionality to it.

最简单的方法是为sql函数调用创建一个包装器并为其添加日志功能。

I'm not sure the file written by the PRAGMA journal_mode is readable, but I couldnt use this pragma.

我不确定PRAGMA journal_mode写的文件是否可读,但我不能使用这个pragma。

You can also have a look at an excellent existing wrapper from Gus Mueller: fmdb

您还可以看看Gus Mueller的优秀现有包装器:fmdb

#2


I don't think this is possible.

我不认为这是可能的。

As far as I know, prepared statements aren't built into "full SQL" strings before they get to the database engine. The parameter values aren't escaped, quoted, and inserted into the SQL string only to be parsed and decoded in the next step: the values bypass the query parsing entirely and go straight into the data engine.

据我所知,准备好的语句在进入数据库引擎之前不会内置到“完整SQL”字符串中。参数值不会被转义,引用和插入到SQL字符串中,只能在下一步中进行解析和解码:这些值会绕过查询完全解析并直接进入数据引擎。