I am very new to scripting, and I have been tasked with figuring out a way to script a shell script that will create sqlSQL queries based on a yaml that is provided YAML document. I was able tocould trace down the parser to yqyq parser to useuse; however, I am stuck aton how to use individual values from the yamlYAML children nodes.
Sample yamlYAML that iI need to parse is:
config:
- system1:
database_name: database1
port: '1234'
table:
- name: table1
values: 'table_id, value1, 30, randomValue'
- name: table2
values: 'table_id, value1, randomValue, randomValue, value2'
- name: table2
values: 'table_id, value2, randomValue, randomValue'
- system2:
database_name: database2
port: '12345'
table:
- name: table4
values: 'table_id, value3, 30, randomValue'
- name: table5
values: 'table_id, randomValue, randomValue, value4'
- name: table6
values: 'table_id, value3, value4'
config:
- system1:
database_name: database1
port: '1234'
table:
- name: table1
values: 'table_id, value1, 30, randomValue'
- name: table2
values: 'table_id, value1, randomValue, randomValue, value2'
- name: table2
values: 'table_id, value2, randomValue, randomValue'
- system2:
database_name: database2
port: '12345'
table:
- name: table4
values: 'table_id, value3, 30, randomValue'
- name: table5
values: 'table_id, randomValue, randomValue, value4'
- name: table6
values: 'table_id, value3, value4'
The script That ithat I am trying to write currently is nothing more than selectSELECT statements,
but it will evolve as i start more on itlater:
//# This will later be used to create insert/update queries based on the values so
//# will be needing a handle for that too.
psql -h localhost -p $PORT -d $DATABaSE$DATABASE << EOF
select * from $TABLE LIMIT 10;
EOF
If possible, without sounding needy i, I would hope to see suggestions on how iI can use yqyq library, given that it supports a bunch of operations that iI will need to do to this script once the sqlSQL part is completed.