Added binding function, and a simple example with an integer value

This commit is contained in:
Sebastien Rombauts
2012-03-31 17:33:27 +02:00
parent 047cbcf637
commit abc1f7bfa3
6 changed files with 114 additions and 29 deletions

View File

@@ -3,25 +3,26 @@
int main (void)
{
std::cout << "Hello SQLite.hpp\n";
try
{
// Open a database file
SQLite::Database db("example.db3");
std::cout << db.getFilename().c_str() << " onpened\n";
std::cout << "SQLite database file '" << db.getFilename().c_str() << "' opened successfully\n";
SQLite::Statement stmt(db, "SELECT * FROM test");
std::cout << "statement created\n";
// Compile a SQL query, containing one parameter (index 1)
SQLite::Statement query(db, "SELECT * FROM test WHERE size>?");
// Bind an integer value "6" to the first parameter of the SQL query
query.bind(1, 6);
while (stmt.executeStep())
while (query.executeStep())
{
std::cout << "executeStep\n";
}
}
catch (std::exception& e)
{
std::cout << "SQLite exception: " << e.what() << std::endl;
std::cout << "SQLite exception: " << e.what() << std::endl;
}
std::cout << "Bye SQLite.hpp\n";
return 0;
}