记录使用SQLiteDatabase SQL语句 [英] Logging SQL statements using SQLiteDatabase

查看:127
本文介绍了记录使用SQLiteDatabase SQL语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想看到SQLiteDatabase产生,理解为什么事情是错的SQL语句。有没有一种方法,使SQLiteDatabase登录到logcat的?

I want to see the SQL statements generated by SQLiteDatabase, to understand why something is wrong. Is there a way to make SQLiteDatabase log to logcat?

谢谢,
  伊泰。

Thanks, Itay.

编辑:这是不一样的android系统 记录SQL查询,我试图登录INSERT和UPDATE语句 - 我没有光标

This is not the same as Logging SQL queries in android, as I'm trying to log insert and update statements - I don't have a cursor.

推荐答案

您必须自己使用跟踪API来实现它,这样你就可以实现的 SQLite的跟踪

You have to implement it by yourself using trace API,so you can implement the callback of SQLite Trace :

)由sqlite3_trace(注册回调函数调用时
  当SQL语句是由sqlite3_step运行不同的时间()。
  该sqlite3_trace()函数调用时需要的一个UTF-8条渲染
  SQL语句文本的语句首先开始执行。额外
  因为每个触发子程序是可能发生sqlite3_trace()回调
  输入。触发器的回调包含一个UTF-8 SQL注释说
  标识触发

The callback function registered by sqlite3_trace() is invoked at various times when an SQL statement is being run by sqlite3_step(). The sqlite3_trace() callback is invoked with a UTF-8 rendering of the SQL statement text as the statement first begins executing. Additional sqlite3_trace() callbacks might occur as each triggered subprogram is entered. The callbacks for triggers contain a UTF-8 SQL comment that identifies the trigger.

)由sqlite3_profile(注册回调函数被调用为
  每个SQL语句完成。该配置文件的回调包含
  原始语句文本和多久的挂钟时间的估计
  该声明采取了运行。轮廓回调时间为单位
  纳秒,但是目前实施只能够
  毫秒的分辨率,以便在时间上六个最低显著数字
  是没有意义的。未来的SQLite版本可能提供更大
  事件探查器回调的分辨率。所述sqlite3_profile()函数是
  认为是实验性,有可能在未来的版本中改变
  SQLite的。

The callback function registered by sqlite3_profile() is invoked as each SQL statement finishes. The profile callback contains the original statement text and an estimate of wall-clock time of how long that statement took to run. The profile callback time is in units of nanoseconds, however the current implementation is only capable of millisecond resolution so the six least significant digits in the time are meaningless. Future versions of SQLite might provide greater resolution on the profiler callback. The sqlite3_profile() function is considered experimental and is subject to change in future versions of SQLite.

这篇关于记录使用SQLiteDatabase SQL语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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