Re: [gnome-db] database xml - add data from model



On Fri, 2003-08-22 at 10:56 +0200, Philippe CHARLIER wrote:
> Le jeu 21/08/2003 à 18:26, Rodrigo Moya a écrit :
> > On Thu, 2003-08-21 at 17:20 +0200, Philippe CHARLIER wrote:
> > > Hi,
> > > 
> > > I am still trying to use an XmlDatabase, I am able to create a file and
> > > define tables.
> > > I just need to do two more things to start using libgda in an
> > > application :
> > > 
> > > - to insert datas in the tables and
> > > - to query those data in the created database.
> > > 
> > > Concerning the insertion of data in the tables, it seems that the
> > > function "gda_table_add_data_from_model()" does nothing and so that for
> > > the moment it is not yet possible to populate an Xml Database with
> > > libgda.
> > > 
> > right, it's empty :-( File a bug to bugzilla please
> 
> I will do that as soon as I find the time to understand how to fill
> correctly a bug with bugzilla ;-)
> 
use bug-buddy. It just asks you for all the relevant information, and it
doesn't need you to create an account on bugzilla.

> > > Could you confirm this ?
> > > If yes, I would be pleased to code that part ... but I have no idea of
> > > the way to do that ;-(
> > > 
> > GdaTable's are just GdaDataModel's, so to add data just use the
> > gda_data_model_append_row function.
> 
> I tried, but it seems I do not understand how those data models are
> working.
> Here is what I did :
> 
> ---------------------------------------------------------------
> 
> void create_tables(GdaXmlDatabase *database) {
>   GdaTable *airport;
>   GdaTable *runway;
> 
>   GdaFieldAttributes *fieldAttributes;
> 
>   GList *airportRow = NULL;
>   GList *runwayRow = NULL;
> 
>   airport = gda_xml_database_new_table(database, "airport");
>   runway = gda_xml_database_new_table(database, "runway");
> 
>   /* 2 columns for table airport : ICAO and IATA          */
>   fieldAttributes = gda_field_attributes_new();
>     /* all attributes set here using a serie of functions */
>     /* gda_field_attributes_set_xxxx()                    */
>   gda_table_add_field(airport, fieldAttributes);
>   fieldAttributes = gda_field_attributes_new();
>     /* all attributes set here using a serie of functions */
>     /* gda_field_attributes_set_xxxx()                    */
>   gda_table_add_field(airport, fieldAttributes);
> 
>   /* 1 column for table runway : DESIGNATOR               */
>   fieldAttributes = gda_field_attributes_new();
>     /* all attributes set here using a serie of functions */
>     /* gda_field_attributes_set_xxxx()                    */
>   gda_table_add_field(runway, fieldAttributes);
> 
>   airportRow = g_list_append(airportRow, "EBBR");
>   airportRow = g_list_append(airportRow, "BRU");
>   runwayRow = g_list_append(runwayRow, "25R");
> 
the GList you use for _append_row is a list of GdaValue's, not of
strings. So:

airportRow = g_list_append (airportRow, gda_value_new_string ("EBBR"));
...
gda_data_model_append_row (model, airportRow);
g_list_foreach (airportRow, gda_value_free, NULL);
g_list_free (airportRow);

the last 2 lines are for freeing the list of values, which is no longer
needed after calling _append_row.

> PS. : I keep track of all my wandering, so I suppose a tutorial
> "gda-xml-database for idiots" is on the launching pad ;-)  
> 
cool! Just add all your notes to the already existing documentation. No
need for a separated document, specially when the docs we've got are
incomplete :-)

You might want, for that, to modify doc/C/tmpl/gda-xml-database.sgml and
gda-xml-database.c itself (for the functions documentation, as you
already did in your patch).

cheers




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