I am very new to scripting, and I have been tasked with figuring out a way to script a shell script that will create SQL queries based on a provided YAML document. I could trace down the yq parser to use; however, I am stuck on how to use individual values from the YAML children nodes.
Sample YAML that I 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'
The script that I am trying to write currently is nothing more than SELECT statements,
but it will evolve later:
# 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 << EOF
select * from $TABLE LIMIT 10;
EOF
If possible, without sounding needy, I would hope to see suggestions on how I can use yq library, given that it supports a bunch of operations that I will need to do to this script once the SQL part is completed.
I apologise if the question is too stupid, it would be my first time on shell scripting.
I am using Ubuntu 18.4 Distribution if that's relevant.
