docs: def store(hdu,dbase='cfeps',duser='cfhls',dtype='MYSQL',table='source'):
      """Write the contents of a MOP data structure to a SQL table"""
  
      import MOPdbaccess
      db=MOPdbaccess.connect(dbase,duser,dbSystem=dtype)
      dbc=db.cursor()
  
      ### INSERT THE 'HEADER' in the meta-data table
      file_id=hdu['header']['image']
      for key in hdu['header'].keys():
          if key == 'image':
              continue
          value=hdu['header'][key]
          ### require that the file_id+keyword is unique
          sql="DELETE FROM metadata WHERE file_id='%s' and keyword='%s' " % ( file_id, key)
          dbc.execute(sql)
          sql="INSERT INTO metadata (file_id, keyword, value) values ('%s','%s','%s' ) "% ( file_id, key, value)
          dbc.execute(sql)
      db.commit()
  
      sql="DELETE FROM source WHERE file_id LIKE '%s'  " % ( file_id )
      dbc.execute(sql)
  
      sql="INSERT INTO %s ( " % ( table)
      sep=" "
      values="("
      cols=hdu['hdu2sql'].keys()
      for col in cols:
          sql+=sep+hdu['hdu2sql'][col]
          values+=sep+" %s " 
          sep=', '
      values+=", '%s', %d, %d )" % ( file_id, int(hdu['header']['EXPNUM']), int(hdu['header']['CHIP'] )-1 )
      sql+=", file_id, expnum, ccd ) VALUES "+values
      #print sql
      #sys.exit()
      #values=[]
      for row in range(len(hdu['data'][cols[0]])):
          value=[]
          for col in cols:
              value.append(hdu['data'][col][row])
          dbc.execute(sql,value)
          
      sql="""insert into source_idx ( sourceID, x, y, z ) SELECT sourceID, 
             (360.0*COS(RADIANS(raDeg))*COS(RADIANS(decDeg))),
             (360.0*SIN(RADIANS(raDeg))*COS(RADIANS(decDeg))),
             (360.0*SIN(RADIANS(decDeg))) FROM source  WHERE file_id='%s'""" % (file_id)
  
      dbc.execute(sql)
      db.commit()
  
      return