The last piece of my script is only pending.
kindly refer to the code below.
master_db_user='root'
master_db_passwd='123'
master_db_port='3306'
master_db_host='localhost'
master_db_name='uppcldashboard'
Now=$(date +"%d-%m-20%Y")
#Preparing script
#SQL_Query='select * from test_table;'
#MySql Command to connect to a database
mysql -u$master_db_user -p$master_db_passwd -D$master_db_name -e 'select * from uppcl_amount_details into outfile "/created_files/uppcl.csv" fields terminated by "," lines terminated by "\n"';
mv /created_files/uppcl.csv /created_files/offline_collection$Now.csv
sed -i "1i ID","Cashier_id","Discom","Division_Code","division_Name" /created_files/offline_collection$Now.csv
echo "End of the Script"
okay the main question is this.. so I have column in my table called posting_dates. because of posting date we are able to know that the data present is the table is of that particular date.
now the issue within my script is that i can't use any variable which chages in the query. it simply doesn't work as it takes the query as a statement.
so basically what i want is this
i to make such a query in which i don't need to mention any date. i want it to fectch data of that particular day. because i can't change the query every single time.
I can't be like where posting_date="2020-03-30", I need something that automatically makes changes in the query everyday. because it is gonna be used to make file of that particular date.
Really need Help on this people.
Thanks and Regards, Sagar Mandal
CURDATE()
, that's all. – Freddy Apr 14 '20 at 14:50$Now
in your SQL query? Something likewhere posting_date="$Now"
. Why won't that work? – terdon Apr 14 '20 at 14:55