Re: [gnome-db] database xml



On Tue, 2003-07-29 at 19:49, Philippe CHARLIER wrote:
> First try :
> -----------
> 
> After your suggestion to use "GdaXmlDatabase" to create a XML database,
> I started to try the different functions available. Find hereunder my
> first try and ... questions.
> Once again sorry if my questions seems to be too simple but I am quite
> new to programmation.
> 
> Thanks for help.
> 
> Phil
> 
> 
> Small code used to create a new database (named "airports") and save it
> on disk.
> 
> Here is the code :
> 
> /**********************************************************************/
> /*  tutorial_005_02.c - libgda first use                              */
> /*                      1. Creation of a new database.                */
> /*                      2. Give it a name.                            */
> /*                      3. Create tables with fields from models.     */
> /*                      4. Save it.                                   */
> /**********************************************************************/
> #include <gnome.h>
> #include <libgda/libgda.h>
> 
> /**********************************************************************/
> /* "do_stuff" function                                                */
> /**********************************************************************/
> void do_stuff(void) {
>   GdaXmlDatabase *database;
>   GdaDataModel *airportModel;
>   GdaDataModel *runwayModel;
> 
>   database = gda_xml_database_new();
>   gda_xml_database_set_name(database, "airports");
> 
>   airportModel = gda_data_model_array_new(6);
>   gda_data_model_set_column_title(airportModel, 0, "ICAO");
>   gda_data_model_set_column_title(airportModel, 1, "IATA");
>   gda_data_model_set_column_title(airportModel, 2, "NAME");
>   gda_data_model_set_column_title(airportModel, 3, "LATITUDE");
>   gda_data_model_set_column_title(airportModel, 4, "LONGITUDE");
>   gda_data_model_set_column_title(airportModel, 5, "ELEVATION");
>   gda_xml_database_new_table_from_model(database, "airport",
>                                         airportModel, TRUE);
> 
you should better use:

GdaTable *table;

table = gda_xml_datanase_new_table (database, "airport");

and then use the GdaTable functions (which is a GdaDataModelArray-based
class) to populate the data and the fields description. GdaTable is just
another GdaDataModel, but it allows the storage of more information
about each field.

> The database is created with the tables, but with no name (what's the
> utility of "gda_xml_database_set_name" ?).
> I expected something like :
> 
> <?xml version="1.0"?>
> <database name="airports">
> ...
> </database>
> 
hm, what version of libgda are you using?

About the permission problem, I think it is also fiuxed in latest libgda
versions.

cheers




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]