DConf Database Suggestion

Jamie McCracken jamiemcc at blueyonder.co.uk
Sun Apr 10 16:01:50 EEST 2005


Kristof Vansant wrote:
> Looks like it also has ldap support :D
> To bad that the documentation on http://www.gnome-db.org/docs/ is down
> at the moment. But I wonder how it handles threads and if it supports
> rollbacks when the backend supports it. 
> Also do I wonder how big the memory usage is and how fast it is.

You can install the docs for it via deb/rpm. (you can also grab the docs 
from cvs)

Then once installed point your browser to :
/usr/share/doc/libgda2-doc/libgda/index.html

I dont know about the threading issues but I would imagine it would be 
similiar to Sqlite in that regard so I wouldn't share open connections 
amongst threads (unless you know the backend can handle that).

The API is not too far away from ADO (it uses a command object for 
executing queries and non-queries).

The effect on speed/memory is probably tiny for a DB as it will 
passthrough most of the work to it.

It also has support for XML queries so you could use it for xml 
databases too.

It has a GdaTransaction object for managing DB transactions. Here's 
example code from the online help for transactions:


  void process_accounts(GdaConnection *connection)
         {
           GdaTransaction *transaction_one, *transaction_two;
           GdaCommand *command;

           transaction_one=gda_transaction_new("accounts1");
           gda_transaction_set_isolation_level(transaction_one,
                    GDA_TRANSACTION_ISOLATION_SERIALIZABLE);
           gda_connection_begin_transaction(connection,transaction_one);

           command=gda_command_new (
                                    "UPDATE accounts SET balance=balance+50"
                                    "WHERE account_code=456",
                                    GDA_COMMAND_TYPE_SQL,
                                    GDA_COMMAND_OPTION_STOP_ON_ERRORS);
           gda_command_set_transaction(command,transaction_one);
           gda_connection_execute_non_query(connection,command,NULL);
           gda_command_free(command);

           command=gda_command_new (
                                    "UPDATE accounts SET balance=balance-50"
                                    "WHERE account_code=12",
                                    GDA_COMMAND_TYPE_SQL,
                                    GDA_COMMAND_OPTION_STOP_ON_ERRORS);
           gda_command_set_transaction(command,transaction_one);
           gda_connection_execute_non_query(connection,command,NULL);
           gda_command_free(command);

           gda_connection_commit_transaction(connection,transaction_one);
           g_object_unref(transaction_one);

           transaction_two=gda_transaction_new("accounts2");
           gda_transaction_set_isolation_level(transaction_two,
                    GDA_TRANSACTION_ISOLATION_SERIALIZABLE);
           gda_connection_begin_transaction(connection,transaction_two);

           command=gda_command_new (
                                    "UPDATE accounts SET 
balance=balance+400"
                                    "WHERE account_code=456",
                                    GDA_COMMAND_TYPE_SQL,
                                    GDA_COMMAND_OPTION_STOP_ON_ERRORS);
           gda_command_set_transaction(command,transaction_two);
           gda_connection_execute_non_query(connection,command,NULL);
           gda_command_free(command);

           command=gda_command_new (
                                    "UPDATE accounts SET 
balance=balance-400"
                                    "WHERE account_code=12",
                                    GDA_COMMAND_TYPE_SQL,
                                    GDA_COMMAND_OPTION_STOP_ON_ERRORS);
           gda_command_set_transaction(command,transaction_two);
           gda_connection_execute_non_query(connection,command,NULL);
           gda_command_free(command);

           gda_connection_rollback_transaction(connection,transaction_two);
           g_object_unref(transaction_one);

           execute_sql_command(connection,"SELECT * FROM accounts");
         }


jamie.



More information about the xdg mailing list