C-API and mysql connection

Kristoffel De Geest kdg1955 at gmail.com
Thu Jun 19 12:04:48 EDT 2014


On Tue, Jun 17, 2014 at 8:07 PM, Derek Atkins <warlord at mit.edu> wrote:
>
> Hi,
>
> Kristoffel De Geest <kdg1955 at gmail.com> writes:
>
> > As an experienced C programmer, I tried to delve into the C-API of GnuCash.
> > Everything seems very straightforward. But I sucker on one important point:
> > how do I link the mysql data to the QofBook structure.
> > Presumably "gnc_sql_init" and "gnc_sql_load" are the appropriate functions.
> > But here I can not find any parameter for the connection string (eg
> > mysql://myName@myhost/myDB). Or I find nowhere a function that initializes
> > all this via configuration files.
> > Is there a template available that can solve my problem or is there a
> > sample source file? The sample programs found at "
> > http://wiki.gnucash.org/wiki/C_API" give no clarity. Even Google could not
> > help me.
>
> In short, you need to initialize the qof_session with the URI.
>
>

Succeeded and I celebrated this with a loud "YES". The suggestion to
look at "qof_session" and the sources
'src/backend/dbi/test/test-dbi.c' and
'src/backend/dbi/test/test-dbi-stuff.c' were very useful.
Thanks.

During "qof_session_destroy" there is still an error/warning : "CRIT
<GLib> g_hash_table_foreach: assertion `version ==
hash_table->version' failed" (twice). At first glance there are no
problems with my application. Maybe in the past I have played a bit
too much with sql? Before I could connect to my DB, I had inserted two
commodities using the sql insert statement, with a generated guid =>
"guid_to_string(qof_instance_get_guid(commodity))".
Or is there something else going on?
I consider this as a problem with a low priority. If I have more time
I will debug "qof_session_destroy" and keep you informed.

Any suggestion to keep my db password secure? For the moment it is
inside the URI, and I consider this insecure. Of course I can put it
encrypted in a hidden read-only file, but maybe someone have a better
suggestion.

--
 kdg1955


More information about the gnucash-user mailing list