Home | News | Documentation | Download

SQLite tutorials

Hi,
Is there some example how to use prepared statement for select objects from SQLite database?
For insertion I used TSQLStatement + SetString/SetInt functions.
But all examples with “select something” contain “raw” sql command passed as string,


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


There is a SQL section in the ROOT tutorials.

Hi,
the problem is that all those tutorials looks like

TString query="select something from table";
TQSLresult *res = sql->Query(query)
... do stuff...

Whereas I would like to have something line TSQLStatement where I have SetInt SetString methods. I don’t see option like passing statement to database and get TSQLResult.

I suppose you want to set options for SQL? You might want to use TXXXSQLSerevr::Exec. It executes the string on the server and returns;

// attempt to enable UTF-8
if(sql->Exec("set character_set_results='utf8';SET NAMES 'utf8'")) 
    cout << "Setting MySQL to UTF8." << endl;
else
    cerr << "Setting MySQL to UTF8 failed." << endl;

Edit Please ignore the above comment. I should have read your post better.

Is such case. If an external library is an option, you can use libfmt

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.