I am trying to query the total count of a partition in BigQuery and store the result in a mysql table. I am doing this for monitoring purpose.
#!/bin/sh
query1="bq query --format=csv 'SELECT COUNT(1) as Count FROM [dataset.tablename] WHERE _PARTITIONTIME = TIMESTAMP(\"$date\")'"
eval result=\$\($query1\)
echo "$result"
bq_insertquery="insert into <<table>>(<<column>>) values(${result})"
echo $bq_insertquery | mysql -u root -p <<dbname>>
Am getting error while insertion in mysql table. This is probably because the variable $result includes both the header and the value, i.e.
Variable $result holds: value with the header
Looks like myquery will be able to insert data, if i get only the value. How should i assign only value to a shell variable, and use it thereafter ?
Edit: Any sql output contains column_name and values. The variable i assigned to store the value from BigQuery also contains both, i.e. column_name and value. I am looking for something which would be helpfull in extracting only value.
