c - How to get exact SQL statement sent to database -


this question has answer here:

i want print out exact sql statement sent database logging purposes. have looked @ sqlite3_sql doesn't print out sql statement, original sql use input sqlite3_prepare_v2.

here function add value row want print sql statement.

int add_value(sqlite3* db, sqlite3_stmt * stmt, const char* oid, const char* value) {     char sql[256] = {0};     sprintf(sql, "update table1 set value=? field1=\"%s\"", oid);     printf("%s\n", sql);      int ret = ::sqlite3_prepare_v2(         db,         sql,         strlen(sql),         &stmt,         0 );      /* how print out sql statement sent database? */      ret = ::sqlite3_bind_text( stmt, 1, value, strlen(value), 0 );     ret = sqlite3_step(stmt);      return ret; } 

for bit of background inserting integers , strings database. use of ? simplify handling of string - ie whether put quotes round value or not dependent on data type. debugging purposes want log sql statements.

both original sql statement , bound parameter values sent database.

there no mechanism read out parameter values. have log values when calling sqlite3_bind_*.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -