How do I insert data into a table using MySQL using shell script? The maximum number of records could change based on a parameter. Should I use a for
loop in shell script embedded with MySQL?
I have attached my attempt below, and its not inserting the record. Can somebody review it and correct me please?
#!/bin/bash
mysql -u root -p"" << EOF
use school;
EOF
echo -n "Enter numebr of Students to enroll"
read i
echo -n "Enter marks"
read marks
for (( i=1; i‹= 10; i++ ))
do
for((sub=1; sub‹= 8; sub++ ))
do
echo "Enter subject name"
read subject
if [$marks=y | y<=100 | y>=0] then
<< EOF
insert into students('id$i',$subject,$marks)
EOF
echo Record Inserted