static gchar **tables_to_copy = NULL;
static gboolean drop_tables = FALSE;
static gchar *output_file = NULL;
+static gboolean explicit = FALSE;
static gboolean verbose = FALSE;
static GdaConnection *gda_conn_ref_db = NULL;
{ "table", 0, 0, G_OPTION_ARG_STRING_ARRAY, &tables_to_copy, "The table/view's name to copy (can be used multiple times)", "TABLE_NAME" },
{ "drop-tables", 0, 0, G_OPTION_ARG_NONE, &drop_tables, "Drop tables before creating new ones", NULL },
{ "output-file", 0, 0, G_OPTION_ARG_FILENAME, &output_file, "Ouput the whole operation in an xmlfile", "FILENAME" },
+ { "explicit", 0, 0, G_OPTION_ARG_NONE, &explicit, "Read schema from sql statement, instead from GdaMetaStore (at least one --table must be provided)", NULL },
{ "verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, "Verbose", NULL },
{ NULL }
};
if (error != NULL)
{
g_warning ("Error executing insert into: %s",
- (error != NULL && error->message != NULL ? error->message : "no details."));
+ error != NULL && error->message != NULL ? error->message : "no details.");
continue;
}
else
{
g_warning ("Error executing select command: %s",
- (error != NULL && error->message != NULL ? error->message : "no details."));
+ error != NULL && error->message != NULL ? error->message : "no details.");
continue;
}
}
mt_column->default_value = gda_value_stringify (gda_column_get_default_value (gda_column));
table->fields = g_slist_append (table->fields, mt_column);
+ /*if (mt_column->column_type == NULL)
+ {
+ mt_column->column_type = g_strdup (gda_server_provider_get_default_dbms_type (gda_connection_get_provider (gda_conn_ref_db),
+ gda_conn_ref_db,
+ mt_column->gtype));
+ }*/
+ if (mt_column->column_type == NULL)
+ {
+ mt_column->column_type = g_strdup ("VARCHAR");
+ }
+
if (verbose)
{
g_printf ("\t\tField: %s - %s - %d - %d - %d - %s\n",
- mt_column->column_name,
- mt_column->column_type,
- mt_column->gtype,
- mt_column->pkey,
- mt_column->nullok,
- mt_column->default_value);
+ mt_column->column_name,
+ mt_column->column_type,
+ mt_column->gtype,
+ mt_column->pkey,
+ mt_column->nullok,
+ mt_column->default_value);
}
field_server_operation (table, op, mt_column, col);
xroot = xmlNewNode (NULL, "gdadbcopy");
}
- update_metastore ();
+ if (explicit)
+ {
+ if (tables_to_copy == NULL)
+ {
+ g_error ("Using parameter --explicit you must provide at least a table with parameter --table.");
+ return 0;
+ }
+ }
+ else
+ {
+ update_metastore ();
+ }
g_printf ("* Reading tables of reference database (%s).\n",
ref_db_cnc);
tables = NULL;
- read_tables ();
+ if (explicit)
+ {
+ read_tables_explicit ();
+ }
+ else
+ {
+ read_tables ();
+ }
g_printf ("* Copying data.\n");
- //copy_data ();
+ copy_data ();
g_printf ("* Reading views.\n");
- //read_views ();
+ read_views ();
if (output_file != NULL)
{