Re: [gnome-db] create/drop table for PostgreSQL.
- From: Bas Driessen <bas driessen xobas com>
- To: rbirdman swiftdsl com au
- Cc: GNOME-DB List <gnome-db-list gnome org>
- Subject: Re: [gnome-db] create/drop table for PostgreSQL.
- Date: Sun, 30 Jan 2005 20:39:32 +1000
On Sat, 2005-01-29 at 19:57 +1100, Robert Bertram wrote:
> >
> > The first round of changes are in regarding new functions
> > "gda_connection_create_table" and "gda_connection_drop_table" for the
> > PostgreSQL provider. This enables you to create/drop a table in a
> > PostgreSQL database using the GDA API. Additional features like multi
> > column indexes etc will follow, once we decide on the correct
> > implementation. I ask the PostgreSQL users/programmers to test this new
> > functionality and also to review the new function
> > postgres_name_from_gda_type() in providers/postgres/gda-postgres-
> > provider.c This function takes care of the mapping between GDA datatypes
> > and PostgreSQL data types. Very important to get this right, so please
> > review and let me know the issues (if any).
> >
> > I will implement similar for MySQL in the next couple of days as well as
> > to find a (n API) solution for multi column indexes.
> Is there a patch for this. I could could do some user testing maybe though
> I have little programming skills. It would be good bit of functionality to
> have added.
>
The changes are applied to the HEAD of the cvs libgda source tree.
Please read page http://www.gnome-db.org/download.php (near the bottom
of the page) of how to download/install the latest (developer) libgda.
If you have any problems, let me know how I can help.
What you have to do in your logic is to create a for loop for all your
columns that you want to include in your table, create a
GdaDataModelColumnAttributes object for that and add that to a GList.
So:
GList *columns = NULL;
GdaDataModelColumnAttributes *dmca;
for (........) {
/* Create new column structure */
dmca = gda_data_model_column_attributes_new();
/* Set all your the parameters */
/* Table Name */
gda_data_model_column_attributes_set_table(dmca, (const gchar
*)your_table_name);
/* Column Name */
gda_data_model_column_attributes_set_name(dmca, (const gchar
*)your_column_name);
etc etc etc
/* Add column structure to the list */
columns = g_list_append(columns, dmca);
}
/* Call create table call */
status = gda_connection_create_table(connection, your_table_name,
columns);
/* Clean up */
g_list_foreach(columns, FreeColumn, NULL);
g_list_free(columns);
The clean up function "FreeColumn" can be something like:
void FreeColumn(gpointer data, gpointer user_data)
{
GdaDataModelColumnAttributes *dmca = (GdaDataModelColumnAttributes
*)data;
gda_data_model_column_attributes_free(dmca);
}
Hope this helps,
Bas.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]