Database Support


#22

Thank you Ankita.
yes now it is working good

Thanks


#23

Did anybody face the error
"unable to open database file" ?

Have just called the CreateDB function provided by Ankita


#24

So if I change the database file location from “data/test.db” to just “test.db”, then the open statement works fine, but the creating a table statement returns a “disk I/O error”.

I am sure its something related to permissions but don’t know what do I need to set.

Also I am running Legato 17.08.1.

And here is the c code

#include “legato.h”
// #include “interfaces.h”
#include “sqlite3.h”

void initOperation()
{
char *sql;
char *zErrMsg = 0;
sqlite3 *db;
// db = null;
// createDb(db);
int rc ;
// sqlite3 *db;
rc = sqlite3_open(“test.db”, &db);
if(!rc){
LE_INFO("Successfully Created ");
}
else {
LE_INFO(“Error in Creating/Opening Db file : %s\n”, sqlite3_errmsg(db));
}

if (db)
{
    LE_INFO("InitOperations Command For Table Creation");
    sql = "create table if not exists test_sqlite(ID int Primary key, valuename text , value int)";
    int rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
    if (!rc)
    {
        LE_INFO("Executed Command For Table Creation");
    }
    else{
        LE_INFO("Error creation : %s",sqlite3_errmsg(db));
    }
}

}

COMPONENT_INIT
{
LE_INFO(“Sample to use Sqlite3 in Legato”);
//Implement functionalities
initOperation();
}


#25

I eventually added it to the rootfs

diff --git a/common/recipes-core/packagegroups/packagegroup-swi-image-target.bb b/common/recipes-core/packagegroups/packagegroup-swi-image-target.bb
index 0bde906..2824e19 100644
--- a/common/recipes-core/packagegroups/packagegroup-swi-image-target.bb
+++ b/common/recipes-core/packagegroups/packagegroup-swi-image-target.bb
@@ -70,3 +70,8 @@ RDEPENDS_${PN} += "rng-tools"
 
 # Add tinucbor to all targets
 RDEPENDS_${PN} += "tinycbor"
+
+# Comb Addons
+RDEPENDS_${PN} += "tzdata"
+RDEPENDS_${PN} += "c-ares"
+RDEPENDS_${PN} += "sqlite3"
diff --git a/common/recipes-legato/legato-af/legato-af_git.bb b/common/recipes-legato/legato-af/legato-af_git.bb
index d9d7efe..3791b95 100644
--- a/common/recipes-legato/legato-af/legato-af_git.bb
+++ b/common/recipes-legato/legato-af/legato-af_git.bb
@@ -16,6 +16,8 @@ DEPENDS += "mtd-utils-native"
 DEPENDS += "curl"
 DEPENDS += "zlib"
 DEPENDS += "tinycbor"
+DEPENDS += "c-ares"
+DEPENDS += "sqlite3"
 
 # Build time dependencies (not in the rootfs image)
 do_compile[depends]  = "legato-tools:do_populate_sysroot"

#26

hi Ankita,

please share the link. i need sqlite3 in my project
many thanks in advance

thanks