Commit 92654cf7 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

SqliteTools: Display the error message when appropriate

parent f11bda07
......@@ -64,8 +64,8 @@ IShow* ShowEpisode::show()
bool ShowEpisode::createTable(sqlite3* dbConnection)
{
const char* req = "CREATE TABLE IF NOT EXISTS ("
"id_episode INTEGER PRIMARY KEY AUTO INCREMENT,"
const char* req = "CREATE TABLE IF NOT EXISTS ShowEpisode("
"id_episode INTEGER PRIMARY KEY AUTOINCREMENT,"
"artwork_url TEXT,"
"episode_number UNSIGNED INT,"
"last_sync_date UNSIGNED INT,"
......
......@@ -9,6 +9,7 @@ bool SqliteTools::createTable( sqlite3 *db, const char* request )
if ( res != SQLITE_OK )
{
std::cerr << "Failed to execute request: " << request << std::endl;
std::cerr << sqlite3_errmsg( db ) << std::endl;
return false;
}
res = sqlite3_step( stmt );
......
......@@ -4,6 +4,7 @@
#include <sqlite3.h>
#include <string>
#include <vector>
#include <iostream>
class SqliteTools
{
......@@ -17,7 +18,11 @@ class SqliteTools
sqlite3_stmt* stmt;
int res = sqlite3_prepare_v2( dbConnection, req, -1, &stmt, NULL );
if ( res != SQLITE_OK )
{
std::cerr << "Failed to execute request: " << req << std::endl;
std::cerr << sqlite3_errmsg( dbConnection ) << std::endl;
return false;
}
if ( foreignKey != 0 )
sqlite3_bind_int( stmt, 1, foreignKey );
res = sqlite3_step( stmt );
......@@ -38,7 +43,11 @@ class SqliteTools
sqlite3_stmt *stmt;
int res = sqlite3_prepare_v2( dbConnection, req, -1, &stmt, NULL );
if ( res != SQLITE_OK )
{
std::cerr << "Failed to execute request: " << req << std::endl;
std::cerr << sqlite3_errmsg( dbConnection ) << std::endl;
return result;
}
sqlite3_bind_int( stmt, 1, primaryKey );
if ( sqlite3_step( stmt ) != SQLITE_ROW )
return result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment