[PLUG] SQLITE 3 C...

Tomas Kuchta tomas.kuchta.lists at gmail.com
Tue Dec 19 21:41:06 UTC 2017


You either need to close and reopen the SQL DB or pass around the handle to
it, so that you can access it outside the scope of a function - main in
your case.

Tomas

On Dec 19, 2017 10:24 AM, "michael" <michael at robinson-west.com> wrote:

> I have no understanding of what the callback function is for.
>
> I have converted a text file to a sqlite3 file successfully
> in C.  Problem is, I had to do all the sqlite3 stuff in
> main.  I want to create the database and write out the
> file in a separate function.  Further, I want to read the
> database and update a local data structure in a separate
> C function so that main can be short.
>
> Another problem, what is the callback function for?
> ...
> char * err_msg;
> char * sql = (char *)calloc(72,sizeof(char *));
> sprintf(sql,("INSERT INTO Steadyshot VALUES(%d,\"%s\",\"%s\");",ski
> p_settings,token[0],token[1]);
> int return_code = sqlite3_exec(db,sql,0,0,&err_msg);
> free(sql);
> ...
>
> Note in sqlite3_exec that the third or fourth argument can be used to
> indicate a callback function.
>
> I don't want to store the contents of the sqlite3 database file in a
> global data structure, but can
> I store it in a local data structure from a callback function?
>
> My goal is to abandon having a text file and just store the settings in a
> sqlite3 file.  This is
> the straightforward way to share settings between a C program and Apache.
>
> I could also use pointers on how to read the database in PHP from the
> Apache side and where the
> database file should be on the Linux filesystem.
> _______________________________________________
> PLUG mailing list
> PLUG at pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>



More information about the PLUG mailing list