#include "table.h"

void makeTable(string tblname,ResultSet& conn){
  /*
    FileReader reader(TABLESPEC);

    conn.query<<"drop table if exists "<<tblname; // Drop the old version of the table if it exists
    conn.store();
    
    // Make the new table
    conn.query<<"create table "<<tblname<<"(";
    if(!reader.eof())
    conn.query<<reader.nextLine();
    while(!reader.eof())
    conn.query<<",\n"<<reader.nextLine();
  
    conn.query<<")";
    conn.store();
  */

  conn.query<<"drop table if exists "<<tblname;
  conn.store();
  conn.query<<"create table "<<tblname<<"("
	    <<"idx int not null auto_increment primary key,"
	    <<"selects varchar(255),"
	    <<"combonum int,"
	    <<"selectednum int,"
	    <<"finished int default 0,"
	    <<"needssams int,"
	    <<"power_ttl_AIR double,"
	    <<"power_ttl_APM double,"
	    <<"power_ttl_CAM double,"
	    <<"power_ttl_HAB double,"
	    <<"power_ttl_JEM double,"
	    <<"power_ttl_JEMEF double,"
	    <<"power_ttl_JEMELMPS double,"
	    <<"power_ttl_LAB double,"
	    <<"power_ttl_NOD1 double,"
	    <<"power_ttl_NOD2 double,"
	    <<"power_ttl_NOD3 double,"
	    <<"power_ttl_TRUSS double,"
	    <<"power_ttl double,"
	    <<"power_xcd_AIR int,"
	    <<"power_xcd_APM int,"
	    <<"power_xcd_CAM int,"
	    <<"power_xcd_HAB int,"
	    <<"power_xcd_JEM int,"
	    <<"power_xcd_JEMEF int,"
	    <<"power_xcd_JEMELMPS int,"
	    <<"power_xcd_LAB int,"
	    <<"power_xcd_NOD1 int,"
	    <<"power_xcd_NOD2 int,"
	    <<"power_xcd_NOD3 int,"
	    <<"power_xcd_TRUSS int,"
	    <<"power_xcd int,"
	    <<"energy_ttl_AIR double,"
	    <<"energy_ttl_APM double,"
	    <<"energy_ttl_CAM double,"
	    <<"energy_ttl_HAB double,"
	    <<"energy_ttl_JEM double,"
	    <<"energy_ttl_JEMEF double,"
	    <<"energy_ttl_JEMELMPS double,"
	    <<"energy_ttl_LAB double,"
	    <<"energy_ttl_NOD1 double,"
	    <<"energy_ttl_NOD2 double,"
	    <<"energy_ttl_NOD3 double,"
	    <<"energy_ttl_TRUSS double,"
	    <<"energy_ttl double,"
	    <<"energy_xcd_AIR int,"
	    <<"energy_xcd_APM int,"
	    <<"energy_xcd_CAM int,"
	    <<"energy_xcd_HAB int,"
	    <<"energy_xcd_JEM int,"
	    <<"energy_xcd_JEMEF int,"
	    <<"energy_xcd_JEMELMPS int,"
	    <<"energy_xcd_LAB int,"
	    <<"energy_xcd_NOD1 int,"
	    <<"energy_xcd_NOD2 int,"
	    <<"energy_xcd_NOD3 int,"
	    <<"energy_xcd_TRUSS int,"
	    <<"energy_xcd int,"
	    <<"energy_crewtend_ttl_AIR double,"
	    <<"energy_crewtend_ttl_APM double,"
	    <<"energy_crewtend_ttl_CAM double,"
	    <<"energy_crewtend_ttl_HAB double,"
	    <<"energy_crewtend_ttl_JEM double,"
	    <<"energy_crewtend_ttl_JEMEF double,"
	    <<"energy_crewtend_ttl_JEMELMPS double,"
	    <<"energy_crewtend_ttl_LAB double,"
	    <<"energy_crewtend_ttl_NOD1 double,"
	    <<"energy_crewtend_ttl_NOD2 double,"
	    <<"energy_crewtend_ttl_NOD3 double,"
	    <<"energy_crewtend_ttl_TRUSS double,"
	    <<"energy_crewtend_ttl double,"
	    <<"energy_crewtend_xcd_AIR int,"
	    <<"energy_crewtend_xcd_APM int,"
	    <<"energy_crewtend_xcd_CAM int,"
	    <<"energy_crewtend_xcd_HAB int,"
	    <<"energy_crewtend_xcd_JEM int,"
	    <<"energy_crewtend_xcd_JEMEF int,"
	    <<"energy_crewtend_xcd_JEMELMPS int,"
	    <<"energy_crewtend_xcd_LAB int,"
	    <<"energy_crewtend_xcd_NOD1 int,"
	    <<"energy_crewtend_xcd_NOD2 int,"
	    <<"energy_crewtend_xcd_NOD3 int,"
	    <<"energy_crewtend_xcd_TRUSS int,"
	    <<"energy_crewtend_xcd double,"
	    <<"LTL_ttl_AIR double,"
	    <<"LTL_ttl_APM double,"
	    <<"LTL_ttl_CAM double,"
	    <<"LTL_ttl_HAB double,"
	    <<"LTL_ttl_JEM double,"
	    <<"LTL_ttl_JEMEF double,"
	    <<"LTL_ttl_JEMELMPS double,"
	    <<"LTL_ttl_LAB double,"
	    <<"LTL_ttl_NOD1 double,"
	    <<"LTL_ttl_NOD2 double,"
	    <<"LTL_ttl_NOD3 double,"
	    <<"LTL_ttl_TRUSS double,"
	    <<"LTL_xcd_AIR int,"
	    <<"LTL_xcd_APM int,"
	    <<"LTL_xcd_CAM int,"
	    <<"LTL_xcd_HAB int,"
	    <<"LTL_xcd_JEM int,"
	    <<"LTL_xcd_JEMEF int,"
	    <<"LTL_xcd_JEMELMPS int,"
	    <<"LTL_xcd_LAB int,"
	    <<"LTL_xcd_NOD1 int,"
	    <<"LTL_xcd_NOD2 int,"
	    <<"LTL_xcd_NOD3 int,"
	    <<"LTL_xcd_TRUSS int,"
	    <<"LTL_xcd double,"
	    <<"MTL_ttl_AIR double,"
	    <<"MTL_ttl_APM double,"
	    <<"MTL_ttl_CAM double,"
	    <<"MTL_ttl_HAB double,"
	    <<"MTL_ttl_JEM double,"
	    <<"MTL_ttl_JEMEF double,"
	    <<"MTL_ttl_JEMELMPS double,"
	    <<"MTL_ttl_LAB double,"
	    <<"MTL_ttl_NOD1 double,"
	    <<"MTL_ttl_NOD2 double,"
	    <<"MTL_ttl_NOD3 double,"
	    <<"MTL_ttl_TRUSS double,"
	    <<"MTL_xcd_AIR int,"
	    <<"MTL_xcd_APM int,"
	    <<"MTL_xcd_CAM int,"
	    <<"MTL_xcd_HAB int,"
	    <<"MTL_xcd_JEM int,"
	    <<"MTL_xcd_JEMEF int,"
	    <<"MTL_xcd_JEMELMPS int,"
	    <<"MTL_xcd_LAB int,"
	    <<"MTL_xcd_NOD1 int,"
	    <<"MTL_xcd_NOD2 int,"
	    <<"MTL_xcd_NOD3 int,"
	    <<"MTL_xcd_TRUSS int,"
	    <<"MTL_xcd double,"
	    <<"MTL_ttl_simul_AIR double,"
	    <<"MTL_ttl_simul_APM double,"
	    <<"MTL_ttl_simul_CAM double,"
	    <<"MTL_ttl_simul_HAB double,"
	    <<"MTL_ttl_simul_JEM double,"
	    <<"MTL_ttl_simul_JEMEF double,"
	    <<"MTL_ttl_simul_JEMELMPS double,"
	    <<"MTL_ttl_simul_LAB double,"
	    <<"MTL_ttl_simul_NOD1 double,"
	    <<"MTL_ttl_simul_NOD2 double,"
	    <<"MTL_ttl_simul_NOD3 double,"
	    <<"MTL_ttl_simul_TRUSS double,"
	    <<"MTL_xcd_simul_AIR int,"
	    <<"MTL_xcd_simul_APM int,"
	    <<"MTL_xcd_simul_CAM int,"
	    <<"MTL_xcd_simul_HAB int,"
	    <<"MTL_xcd_simul_JEM int,"
	    <<"MTL_xcd_simul_JEMEF int,"
	    <<"MTL_xcd_simul_JEMELMPS int,"
	    <<"MTL_xcd_simul_LAB int,"
	    <<"MTL_xcd_simul_NOD1 int,"
	    <<"MTL_xcd_simul_NOD2 int,"
	    <<"MTL_xcd_simul_NOD3 int,"
	    <<"MTL_xcd_simul_TRUSS int,"
	    <<"MTL_simul_xcd double,"
	    <<"LTL_ttl_simul_AIR double,"
	    <<"LTL_ttl_simul_APM double,"
	    <<"LTL_ttl_simul_CAM double,"
	    <<"LTL_ttl_simul_HAB double,"
	    <<"LTL_ttl_simul_JEM double,"
	    <<"LTL_ttl_simul_JEMEF double,"
	    <<"LTL_ttl_simul_JEMELMPS double,"
	    <<"LTL_ttl_simul_LAB double,"
	    <<"LTL_ttl_simul_NOD1 double,"
	    <<"LTL_ttl_simul_NOD2 double,"
	    <<"LTL_ttl_simul_NOD3 double,"
	    <<"LTL_ttl_simul_TRUSS double,"
	    <<"LTL_xcd_simul_AIR int,"
	    <<"LTL_xcd_simul_APM int,"
	    <<"LTL_xcd_simul_CAM int,"
	    <<"LTL_xcd_simul_HAB int,"
	    <<"LTL_xcd_simul_JEM int,"
	    <<"LTL_xcd_simul_JEMEF int,"
	    <<"LTL_xcd_simul_JEMELMPS int,"
	    <<"LTL_xcd_simul_LAB int,"
	    <<"LTL_xcd_simul_NOD1 int,"
	    <<"LTL_xcd_simul_NOD2 int,"
	    <<"LTL_xcd_simul_NOD3 int,"
	    <<"LTL_xcd_simul_TRUSS int,"
	    <<"LTL_simul_xcd double,"
	    <<"MTL_crewtend_ttl_AIR double,"
	    <<"MTL_crewtend_ttl_APM double,"
	    <<"MTL_crewtend_ttl_CAM double,"
	    <<"MTL_crewtend_ttl_HAB double,"
	    <<"MTL_crewtend_ttl_JEM double,"
	    <<"MTL_crewtend_ttl_JEMEF double,"
	    <<"MTL_crewtend_ttl_JEMELMPS double,"
	    <<"MTL_crewtend_ttl_LAB double,"
	    <<"MTL_crewtend_ttl_NOD1 double,"
	    <<"MTL_crewtend_ttl_NOD2 double,"
	    <<"MTL_crewtend_ttl_NOD3 double,"
	    <<"MTL_crewtend_ttl_TRUSS double,"
	    <<"MTL_crewtend_xcd_AIR int,"
	    <<"MTL_crewtend_xcd_APM int,"
	    <<"MTL_crewtend_xcd_CAM int,"
	    <<"MTL_crewtend_xcd_HAB int,"
	    <<"MTL_crewtend_xcd_JEM int,"
	    <<"MTL_crewtend_xcd_JEMEF int,"
	    <<"MTL_crewtend_xcd_JEMELMPS int,"
	    <<"MTL_crewtend_xcd_LAB int,"
	    <<"MTL_crewtend_xcd_NOD1 int,"
	    <<"MTL_crewtend_xcd_NOD2 int,"
	    <<"MTL_crewtend_xcd_NOD3 int,"
	    <<"MTL_crewtend_xcd_TRUSS int,"
	    <<"MTL_crewtend_xcd double,"
	    <<"LTL_crewtend_ttl_AIR double,"
	    <<"LTL_crewtend_ttl_APM double,"
	    <<"LTL_crewtend_ttl_CAM double,"
	    <<"LTL_crewtend_ttl_HAB double,"
	    <<"LTL_crewtend_ttl_JEM double,"
	    <<"LTL_crewtend_ttl_JEMEF double,"
	    <<"LTL_crewtend_ttl_JEMELMPS double,"
	    <<"LTL_crewtend_ttl_LAB double,"
	    <<"LTL_crewtend_ttl_NOD1 double,"
	    <<"LTL_crewtend_ttl_NOD2 double,"
	    <<"LTL_crewtend_ttl_NOD3 double,"
	    <<"LTL_crewtend_ttl_TRUSS double,"
	    <<"LTL_crewtend_xcd_AIR int,"
	    <<"LTL_crewtend_xcd_APM int,"
	    <<"LTL_crewtend_xcd_CAM int,"
	    <<"LTL_crewtend_xcd_HAB int,"
	    <<"LTL_crewtend_xcd_JEM int,"
	    <<"LTL_crewtend_xcd_JEMEF int,"
	    <<"LTL_crewtend_xcd_JEMELMPS int,"
	    <<"LTL_crewtend_xcd_LAB int,"
	    <<"LTL_crewtend_xcd_NOD1 int,"
	    <<"LTL_crewtend_xcd_NOD2 int,"
	    <<"LTL_crewtend_xcd_NOD3 int,"
	    <<"LTL_crewtend_xcd_TRUSS int,"
	    <<"LTL_crewtend_xcd double,"
	    <<"acoustics_ttl_AIR double,"
	    <<"acoustics_ttl_APM double,"
	    <<"acoustics_ttl_CAM double,"
	    <<"acoustics_ttl_HAB double,"
	    <<"acoustics_ttl_JEM double,"
	    <<"acoustics_ttl_JEMEF double,"
	    <<"acoustics_ttl_JEMELMPS double,"
	    <<"acoustics_ttl_LAB double,"
	    <<"acoustics_ttl_NOD1 double,"
	    <<"acoustics_ttl_NOD2 double,"
	    <<"acoustics_ttl_NOD3 double,"
	    <<"acoustics_ttl_TRUSS double,"
	    <<"acoustics_xcd_AIR int,"
	    <<"acoustics_xcd_APM int,"
	    <<"acoustics_xcd_CAM int,"
	    <<"acoustics_xcd_HAB int,"
	    <<"acoustics_xcd_JEM int,"
	    <<"acoustics_xcd_JEMEF int,"
	    <<"acoustics_xcd_JEMELMPS int,"
	    <<"acoustics_xcd_LAB int,"
	    <<"acoustics_xcd_NOD1 int,"
	    <<"acoustics_xcd_NOD2 int,"
	    <<"acoustics_xcd_NOD3 int,"
	    <<"acoustics_xcd_TRUSS int,"
	    <<"acoustics_xcd int,"
	    <<"acoustics_ttl_simul_AIR double,"
	    <<"acoustics_ttl_simul_APM double,"
	    <<"acoustics_ttl_simul_CAM double,"
	    <<"acoustics_ttl_simul_HAB double,"
	    <<"acoustics_ttl_simul_JEM double,"
	    <<"acoustics_ttl_simul_JEMEF double,"
	    <<"acoustics_ttl_simul_JEMELMPS double,"
	    <<"acoustics_ttl_simul_LAB double,"
	    <<"acoustics_ttl_simul_NOD1 double,"
	    <<"acoustics_ttl_simul_NOD2 double,"
	    <<"acoustics_ttl_simul_NOD3 double,"
	    <<"acoustics_ttl_simul_TRUSS double,"
	    <<"acoustics_xcd_simul_AIR int,"
	    <<"acoustics_xcd_simul_APM int,"
	    <<"acoustics_xcd_simul_CAM int,"
	    <<"acoustics_xcd_simul_HAB int,"
	    <<"acoustics_xcd_simul_JEM int,"
	    <<"acoustics_xcd_simul_JEMEF int,"
	    <<"acoustics_xcd_simul_JEMELMPS int,"
	    <<"acoustics_xcd_simul_LAB int,"
	    <<"acoustics_xcd_simul_NOD1 int,"
	    <<"acoustics_xcd_simul_NOD2 int,"
	    <<"acoustics_xcd_simul_NOD3 int,"
	    <<"acoustics_xcd_simul_TRUSS int,"
	    <<"acoustics_xcd_simul int,"
	    <<"acoustics_crewtend_ttl_AIR double,"
	    <<"acoustics_crewtend_ttl_APM double,"
	    <<"acoustics_crewtend_ttl_CAM double,"
	    <<"acoustics_crewtend_ttl_HAB double,"
	    <<"acoustics_crewtend_ttl_JEM double,"
	    <<"acoustics_crewtend_ttl_JEMEF double,"
	    <<"acoustics_crewtend_ttl_JEMELMPS double,"
	    <<"acoustics_crewtend_ttl_LAB double,"
	    <<"acoustics_crewtend_ttl_NOD1 double,"
	    <<"acoustics_crewtend_ttl_NOD2 double,"
	    <<"acoustics_crewtend_ttl_NOD3 double,"
	    <<"acoustics_crewtend_ttl_TRUSS double,"
	    <<"acoustics_crewtend_xcd_AIR int,"
	    <<"acoustics_crewtend_xcd_APM int,"
	    <<"acoustics_crewtend_xcd_CAM int,"
	    <<"acoustics_crewtend_xcd_HAB int,"
	    <<"acoustics_crewtend_xcd_JEM int,"
	    <<"acoustics_crewtend_xcd_JEMEF int,"
	    <<"acoustics_crewtend_xcd_JEMELMPS int,"
	    <<"acoustics_crewtend_xcd_LAB int,"
	    <<"acoustics_crewtend_xcd_NOD1 int,"
	    <<"acoustics_crewtend_xcd_NOD2 int,"
	    <<"acoustics_crewtend_xcd_NOD3 int,"
	    <<"acoustics_crewtend_xcd_TRUSS int,"
	    <<"acoustics_crewtend_xcd int,"
	    <<"nominal_uplink_ttl double,"
	    <<"nominal_uplink_xcd int,"
	    <<"peak_uplink_ttl double,"
	    <<"peak_uplink_xcd int,"
	    <<"peak_uplink_duration_ttl double,"
	    <<"peak_uplink_duration_xcd int,"
	    <<"nominal_downlink_ttl double,"
	    <<"nominal_downlink_xcd int,"
	    <<"peak_downlink_ttl double,"
	    <<"peak_downlink_xcd int,"
	    <<"peak_downlink_duration_ttl double,"
	    <<"peak_downlink_duration_xcd int,"
	    <<"nominal_ethernet_ttl double,"
	    <<"nominal_ethernet_xcd int,"
	    <<"peak_ethernet_ttl double,"
	    <<"peak_ethernet_xcd int,"
	    <<"peak_ethernet_duration_ttl double,"
	    <<"peak_ethernet_duration_xcd int,"
	    <<"nominal_1553_ttl double,"
	    <<"nominal_1553_xcd int,"
	    <<"peak_1553_ttl double,"
	    <<"peak_1553_xcd int,"
	    <<"peak_1553_duration_ttl double,"
	    <<"peak_1553_duration_xcd int,"
	    <<"nominal_HRL_ttl double,"
	    <<"nominal_HRL_xcd int,"
	    <<"peak_HRL_ttl double,"
	    <<"peak_HRL_xcd int,"
	    <<"peak_HRL_duration_ttl double,"
	    <<"peak_HRL_duration_xcd int,"
	    <<"video_uplink_ttl double,"
	    <<"video_uplink_xcd int,"
	    <<"video_downlink_ttl double,"
	    <<"video_downlink_xcd int,"
	    <<"video_rate_ttl double,"
	    <<"video_rate_xcd int,"
	    <<"keepalive_ttl double,"
	    <<"keepalive_xcd int,"
	    <<"middecks_ttl double,"
	    <<"middecks_xcd int,"
	    <<"stowage_ttl double,"
	    <<"stowage_xcd int,"
	    <<"upmass_ttl double,"
	    <<"upmass_xcd int,"
	    <<"crewtrng_ttl double,"
	    <<"crewtrng_xcd int,"
	    <<"crewtime_ttl double,"
	    <<"crewtime_xcd int,"
	    <<"runtime_ttl double,"

	    <<"cs_p4_asc_xcd int,"
	    <<"cs_p4_asc_ttl double,"
	    <<"cs_p4_orb_xcd int,"
	    <<"cs_p4_orb_ttl double,"
	    <<"cs_p4_desc_xcd int,"
	    <<"cs_p4_desc_ttl double,"
	    <<"cs_m20_asc_xcd int,"
	    <<"cs_m20_asc_ttl double,"
	    <<"cs_m20_orb_xcd int,"
	    <<"cs_m20_orb_ttl double,"
	    <<"cs_m20_desc_xcd int,"
	    <<"cs_m20_desc_ttl double,"
	    <<"cs_m80_asc_xcd int,"
	    <<"cs_m80_asc_ttl double,"
	    <<"cs_m80_orb_xcd int,"
	    <<"cs_m80_orb_ttl double,"
	    <<"cs_m80_desc_xcd int,"
	    <<"cs_m80_desc_ttl double,"
	    <<"cs_m180_asc_xcd int,"
	    <<"cs_m180_asc_ttl double,"
	    <<"cs_m180_orb_xcd int,"
	    <<"cs_m180_orb_ttl double,"
	    <<"cs_m180_desc_xcd int,"
	    <<"cs_m180_desc_ttl double,"

	    <<"any_exceeded_inc int,"
	    <<"any_exceeded_simul int)";
  conn.store();
  //cout<<"Table "<<tblname<<" made successfully.\n";
}
