IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38977


Ignore:
Timestamp:
Oct 27, 2015, 3:54:14 PM (11 years ago)
Author:
eugene
Message:

add option to supply the output table name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150625/Ohana/src/tools/src/fits_to_mysql.c

    r38976 r38977  
    5151char        *DATABASE_PASS;
    5252char        *DATABASE_NAME;
     53char        *TABLENAME;
    5354
    5455int args (int *argc, char **argv);
     
    9495
    9596  int Nsection = 0;
     97  int Ntable = 0;
    9698  while (gfits_fread_header (f, &header)) {
    9799
     
    143145    InitIOBuffer (&insert, 1024);
    144146
     147    if ((Ntable > 0) && TABLENAME) {
     148      fprintf (stderr, "WARNING: table name is supplied but more than one table is read: earlier tables will be replaced\n");
     149    }
    145150    create_table (columns, Ncolumns, extname, &insert, mysqlReal);
    146151
     
    174179    fseeko (f, Nbytes, SEEK_CUR);
    175180    Nsection ++;
     181    Ntable ++;
    176182
    177183    FreeColumnDef (columns, Ncolumns);
     
    186192  FREE (DATABASE_PASS);
    187193  FREE (DATABASE_NAME);
     194  FREE (TABLENAME);
    188195
    189196  ohana_memdump (TRUE);
     
    301308  InitIOBuffer (&buffer, 1024);
    302309
    303   char *tablename = strcreate (extname);
     310  char *tablename = TABLENAME ? strcreate (TABLENAME) : strcreate (extname);
    304311  replace_dot_with_underscore (tablename);
    305312
     
    688695  } else usage();
    689696
     697  TABLENAME = NULL;
     698  if ((N = get_argument (*argc, argv, "-tablename"))) {
     699    remove_argument (N, argc, argv);
     700    TABLENAME = strcreate (argv[N]);
     701    remove_argument (N, argc, argv);
     702  }
     703
    690704  return TRUE;
    691705}
Note: See TracChangeset for help on using the changeset viewer.