Skip to content

3. Adding records(WebAPI support)

Python API

  • add_record ( record_list, res_init_json, data_name, options )

Parameters

Parameter Details
record_list record definition associative array
res_init_json associative array object
data_name unique name associated with the event table
options Specify the operation when the attributes (start_datetime, end_datetime, geometry)corresponding to the unique key have already been registered when adding a record
override:overwrite update
skip:do not register the corresponding line
error:do not register all lines

Return values

Value Details
Number of additional records addition successed
less than 0 addition failed
See 4. List of Error Codes for details.

Sample parameter settings

Parameter Samples
record_set
[{'start_datetime': '2020-10-19 00:00:00', 'end_datetime': '2020-10-19 01:00:00',
'no2': '1.23', 'location': {'type': 'Point', 'coordinates': [139.6, 35.6]}}]
res_init_json return value of init_record
data_name 'aerosol_soramame'
options 'override'

Notes

  • Record difinition must be event data format. See 7. Remarks for details about the event data format.
  • start_datetime and end_detetime in record_set must be string types (NOT datetime types).
  • geometry in each record difinition must be GeoJSON format (NOT Well-Known Binary format. Please convert with ST_As_GeoJSON PostGIS function or similar).
  • This API automatically determine and execute INSERT or COPY commands.

Sample source code

  # Record Addition Parameter Setting
  one_record_dic = {}
  one_record_dic['start_datetime'] = '2020-10-19 00:00:00'
  one_record_dic['end_datetime'] = '2020-10-19 01:00:00'
  one_record_dic['so2'] = '1.23'  
  one_record_dic['no'] = '1.27'  
  one_record_dic['no2'] = '2.34'  
  one_record_dic['nox'] = '3.45'  
  one_record_dic['co'] = '4.56'  
  one_record_dic['ox'] = '5.67'  
  one_record_dic['nmhc'] = '6.78'  
  one_record_dic['ch4'] = '7.89'  
  one_record_dic['thc'] = '8.90'  
  one_record_dic['spm'] = '9.01'  
  one_record_dic['pm2.5'] = '0.12'  
  one_record_dic['sp'] = '1.23'  
  one_record_dic['ws'] = '2.34'  
  one_record_dic['temp'] = '3.45'  
  one_record_dic['hum'] = '4.56'  
  one_record_dic['wd'] = 'NNE'  
  one_record_dic['location'] = {}
  one_record_dic['location']['type'] = "Point"
  one_record_dic['location']['coordinates'] = [139.6, 35.6]
  record_list.append(one_record_dic)

  # Record Addition
  add_record(record_list, res_init_json, data_name, options)  

back