# Database Support

**URL:** <https://mangoh.discourse.group/t/database-support/93>\
**Category:** Uncategorized\
**Created:** [June 2, 2016, 6:29am UTC](https://mangoh.discourse.group/t/database-support/93 "2016-06-02T06:29:02Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![niladridm](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/niladridm/32/91_2.png) [@niladridm](https://mangoh.discourse.group/u/niladridm)\
**Post date:** [July 19, 2017, 9:29am UTC](https://mangoh.discourse.group/t/database-support/93/22 "2017-07-19T09:29:12Z")

</div>

Thank you Ankita.  
yes now it is working good

Thanks

---

<div class="post-metadata">

**Author:** ![neobaba](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/neobaba/32/280_2.png) [@neobaba](https://mangoh.discourse.group/u/neobaba)\
**Post date:** [October 17, 2017, 10:12am UTC](https://mangoh.discourse.group/t/database-support/93/23 "2017-10-17T10:12:15Z")

</div>

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

Have just called the CreateDB function provided by Ankita

---

<div class="post-metadata">

**Author:** ![neobaba](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/neobaba/32/280_2.png) [@neobaba](https://mangoh.discourse.group/u/neobaba)\
**Post date:** [October 17, 2017, 12:08pm UTC](https://mangoh.discourse.group/t/database-support/93/24 "2017-10-17T12:08:37Z")

</div>

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();  
}

---

<div class="post-metadata">

**Author:** ![gregnietsky](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/gregnietsky/32/66_2.png) [@gregnietsky](https://mangoh.discourse.group/u/gregnietsky)\
**Post date:** [November 23, 2017, 8:13pm UTC](https://mangoh.discourse.group/t/database-support/93/25 "2017-11-23T20:13:01Z")

</div>

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"
```

---

<div class="post-metadata">

**Author:** ![muradali](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@muradali](https://mangoh.discourse.group/u/muradali)\
**Post date:** [November 14, 2018, 10:39am UTC](https://mangoh.discourse.group/t/database-support/93/26 "2018-11-14T10:39:35Z")

</div>

hi Ankita,

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

thanks

---

<div class="post-metadata">

**Author:** ![kalaivani](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/kalaivani/32/2183_2.png) [@kalaivani](https://mangoh.discourse.group/u/kalaivani)\
**Post date:** [January 2, 2021, 11:51am UTC](https://mangoh.discourse.group/t/database-support/93/27 "2021-01-02T11:51:04Z")

</div>

hi i added the SQlite3 through image . Now i need to add the Sqlite3 in my program can any one guide how to add the Sqlite3 in legato program

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [January 2, 2021, 12:52pm UTC](https://mangoh.discourse.group/t/database-support/93/28 "2021-01-02T12:52:34Z")

</div>

Did you follow the above method?

> [@Database Support](https://mangoh.discourse.group/t/database-support/93/15):
>
> Hi Nila , Please download the Source code present [https://sqlite.org/download.html](https://sqlite.org/download.html) i.e sqlite-amalgamation-3190300.zip Make a folder structure for Sqlite3 as mkdir third-party cd third-party mkdir inc mkdir src mkdir lib Copy sqlite3.h in third-party/inc/ sqlite3.c in third-party/src/ Create a Makefile in path third-party/src/ vi Makefile add following lines export TOOLCHAIN\_DIR:=/opt/swi/y17-ext/sysroots/x86\_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi GCC = ${TOOLCHAIN…

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [March 22, 2021, 9:24pm UTC](https://mangoh.discourse.group/t/database-support/93/29 "2021-03-22T21:24:14Z")

</div>

Hi Ankita,

I got the following error while executing makefile:

> /opt/swi/y17-ext/sysroots/x86\_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc -c -Wall -Werror -fpic -lpthread -ldl sqlite3.c -o …/lib/sqlite3.so  
> make: /opt/swi/y17-ext/sysroots/x86\_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc: Command not found  
> Makefile:4: recipe for target ‘all’ failed  
> make: \*\*\* [all] Error 127

this is what /opt/swi has:  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/8/8fb2edba977ca698ae208f069d4eced7bb9ebf2b.png)

------------UPDATE---------------  
I changed

> /opt/swi/_ **y17-ext** _/sysroots/x86\_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/

to

> /opt/swi/ **y22-ext-wp77xx** /sysroots/x86\_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/

then got the following:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/5/54144d89310517a61b572e2ba9bc9fd67263b7bc.png)

How could I fix it?  
thanks

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [March 23, 2021, 12:06am UTC](https://mangoh.discourse.group/t/database-support/93/30 "2021-03-23T00:06:00Z")

</div>

I have similar problem in WP76 before, you can install some old toolchain like R9 of wp77

> **[\[WP7608\]\[CrossCompile\] Cross compile error for native C source](https://forum.legato.io/t/wp7608-crosscompile-cross-compile-error-for-native-c-source/4954/2)**
>
> Can you download the 64bit toolchain from FW R9? https://source.sierrawireless.com/resources/airprime/software/wp76xx/wp76xx-firmware-release-9-components/#sthash.c1Pa64qx.dpbs Install it to /opt/swi/y22-ext folder. After that you can compile the...

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [March 23, 2021, 4:48am UTC](https://mangoh.discourse.group/t/database-support/93/31 "2021-03-23T04:48:05Z")

</div>

Hi jyijyi,

The link couldn’t be opened up: [https://source.sierrawireless.com/resources/airprime/software/wp76xx/wp76xx-firmware-release-9-components/#sthash.c1Pa64qx.dpbs](https://source.sierrawireless.com/resources/airprime/software/wp76xx/wp76xx-firmware-release-9-components/#sthash.c1Pa64qx.dpbs)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [March 23, 2021, 4:59am UTC](https://mangoh.discourse.group/t/database-support/93/32 "2021-03-23T04:59:44Z")

</div>

that link is for WP76.  
didn’t you are using WP77?  
I saw you already have WP77 R9.1 toolchain.

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [March 23, 2021, 5:03am UTC](https://mangoh.discourse.group/t/database-support/93/33 "2021-03-23T05:03:59Z")

</div>

yes I’m using wp7702. Can you post the link for me?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [March 23, 2021, 5:25am UTC](https://mangoh.discourse.group/t/database-support/93/34 "2021-03-23T05:25:23Z")

</div>

didn’t you already have it?  
/opt/swi/y22-ext-wp77xx-Release\_9.1

Currently [source.sierrawireless.com](http://source.sierrawireless.com) is down…

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [March 23, 2021, 5:35am UTC](https://mangoh.discourse.group/t/database-support/93/35 "2021-03-23T05:35:16Z")

</div>

yes the website is under the maintenance.  
So you meant change

> /opt/swi/ **y22-ext-wp77xx** /sysroots/x86\_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/  
> to

> /opt/swi/ **y22-ext-wp77xx-Release\_9.1** /sysroots/x86\_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/

but got the same error:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/f/fba0a6d6ecc60aa5bd39312da4e59aced88f59a1.png)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [March 23, 2021, 5:40am UTC](https://mangoh.discourse.group/t/database-support/93/36 "2021-03-23T05:40:53Z")

</div>

Can you try the hello.c first?

\<Hello.c\>  
#include\<stdio.h\>  
int main(void)  
{  
printf(“Hello,World\n”);  
return 0;  
}

Btw, you can also check if you can download the old toolchain of wp76 by LEAF

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [March 23, 2021, 6:09am UTC](https://mangoh.discourse.group/t/database-support/93/37 "2021-03-23T06:09:40Z")

</div>

How do I run a native c program in legato?  
and what is LEAF command to download old toolchain of wp76?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [March 23, 2021, 6:19am UTC](https://mangoh.discourse.group/t/database-support/93/38 "2021-03-23T06:19:03Z")

</div>

you are trying to compile a library of sqlite3.so so that it can be called inside legato application, but not trying to run a native c program in legato.

To search for old toolchain, you can use “leaf search”, i already saw some old package:

swi-wp76\_1.0.0 │ SDK for WP76 (Release 9 + Legato 18.03.0)  
│ swi-wp76\_1.2.0 │ SDK for WP76 (Release 9 + Legato 18.05.0)  
│ swi-wp76\_1.2.1 │ SDK for WP76 (Release 9 + Legato 18.05.1)  
│ swi-wp76\_1.3.0 │ SDK for WP76 (Release 9 + Legato 18.06.0)  
│ swi-wp76\_1.3.1 │ SDK for WP76 (Release 9 + Legato 18.06.1)  
│ swi-wp76\_1.3.2 │ SDK for WP76 (Release 9 + Legato 18.06.2)

For download, you can see here:  
[https://docs.legato.io/latest/toolsLeafSetup.html](https://docs.legato.io/latest/toolsLeafSetup.html)

If you have vscode, you can see the UI like this for download:  
[https://docs.legato.io/latest/tools\_vsCodeInstall.html](https://docs.legato.io/latest/tools_vsCodeInstall.html)

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [March 23, 2021, 6:46am UTC](https://mangoh.discourse.group/t/database-support/93/39 "2021-03-23T06:46:23Z")

</div>

This is what I got when run hello.c in legato application:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/8/81e92990813f78571b5485fbb8c7ead6a02eaf8a.png)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [March 23, 2021, 6:56am UTC](https://mangoh.discourse.group/t/database-support/93/40 "2021-03-23T06:56:11Z")

</div>

I am saying this:  
/opt/swi/y22-ext-wp77xx-Release\_9.1/sysroots/x86\_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc -o Hello.o ./hello.c

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [March 23, 2021, 7:11am UTC](https://mangoh.discourse.group/t/database-support/93/41 "2021-03-23T07:11:30Z")

</div>

the same error was produced:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/3/327be8a259f43a9c0dbbc46757ef6cfed1218847.png)

[Previous page](https://mangoh.discourse.group/t/database-support/93.md?page=1)

[Next page](https://mangoh.discourse.group/t/database-support/93.md?page=3)
