分享

Enable Query Logging in SQLite 3

 quasiceo 2012-12-29

Is there any built-in function to enable query log in SQLite.

I am familiar with Trace API, but I want to know if there is any predefined function for it.

share|improve this question

feedback

1 Answer

up vote 1 down vote accepted

Interesting question. I came here intrigued and wondered why I never asked this myself...

One:

Apparently some wrapper-libraries have something like this built-in. But to find a wrapper library you would probably first need to identify the target language. Perl DBI? Python? C++?

Two:

I would not (in any way) recommend the following for a "production-grade" solution, but if you are mainly experimenting and/or debugging, then you might try examining the rollback journal just prior to the end of each transaction. See here about the rollback journal: http://www./tempfiles.html How you would detect 'the end of each transaction' would be up to your code and/or the breakpoints in your debugger.

I must emphasize again: what I just mentioned above would be a total hack-around, and I feel dirty even having mentioned it.

Three:

You could ask on the (very active and gracious) sqlite mailing list, but they would probably just reemphasize sqlite3_trace.

... other random thing:

On a somewhat (barely?) related note, when you start a './sqlite3' command prompt session, you can type:

.explain

which enables interesting and instructive verbose output for each query executed at the prompt.

More Info I Just Found:

One of the flags that can be passed to 'sqlite3_config()' is SQLITE_CONFIG_LOG. This is another way (in addition to the trace API) to set a callback and receive status information from the sqlite library periodically. I think it is mainly for error log messages.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多