Index: /branches/eam_branches/ipp-20150625/Ohana/src/tools/src/fits_to_mysql.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/tools/src/fits_to_mysql.c	(revision 38976)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/tools/src/fits_to_mysql.c	(revision 38977)
@@ -51,4 +51,5 @@
 char        *DATABASE_PASS;
 char        *DATABASE_NAME;
+char        *TABLENAME;
 
 int args (int *argc, char **argv);
@@ -94,4 +95,5 @@
 
   int Nsection = 0;
+  int Ntable = 0;
   while (gfits_fread_header (f, &header)) {
 
@@ -143,4 +145,7 @@
     InitIOBuffer (&insert, 1024);
 
+    if ((Ntable > 0) && TABLENAME) {
+      fprintf (stderr, "WARNING: table name is supplied but more than one table is read: earlier tables will be replaced\n");
+    } 
     create_table (columns, Ncolumns, extname, &insert, mysqlReal);
 
@@ -174,4 +179,5 @@
     fseeko (f, Nbytes, SEEK_CUR);
     Nsection ++;
+    Ntable ++;
 
     FreeColumnDef (columns, Ncolumns);
@@ -186,4 +192,5 @@
   FREE (DATABASE_PASS);
   FREE (DATABASE_NAME);
+  FREE (TABLENAME);
 
   ohana_memdump (TRUE);
@@ -301,5 +308,5 @@
   InitIOBuffer (&buffer, 1024);
 
-  char *tablename = strcreate (extname);
+  char *tablename = TABLENAME ? strcreate (TABLENAME) : strcreate (extname);
   replace_dot_with_underscore (tablename);
 
@@ -688,4 +695,11 @@
   } else usage();
 
+  TABLENAME = NULL;
+  if ((N = get_argument (*argc, argv, "-tablename"))) {
+    remove_argument (N, argc, argv);
+    TABLENAME = strcreate (argv[N]);
+    remove_argument (N, argc, argv);
+  }
+
   return TRUE;
 }
