| GNOME Data Access 4.0 manual |
|---|
First of all you have to initialise the gda library, i.e. to call the gda_init () function, for example:
gda_init ("TestGDA", "0.1", argc, argv);
After initialising you can work as usual or make libgda call a custom defined function calling gda_main_run() (note that if you use this way you will need to call gda_main_quit() in order to finish the program).
For example a basic program would look like:
void
do_stuff ()
{
GdaConnection *connection;
/* open a connection */
g_print ("CONNECTING\n");
connection = gda_connection_open_from_dsn ("calvaris", NULL, NULL, GDA_CONNECTION_OPTIONS_READ_ONLY);
g_print ("CONNECTED\n");
/* use the connection */
execute_some_queries (connection);
/* close the connection */
g_object_unref (G_OBJECT (connection));
}
int
main (int argc, char **argv)
{
g_print ("STARTING\n");
gda_init ("TestGDA", "0.1", argc, argv);
do_stuff();
g_print("ENDING\n");
}