-1

How to email the status of a database transaction

Scenario : "UPDATE xxx SET xxxx=1111 where yyy=111;

I need to trigger a mail the status whether the value got updated in db or not.How can i do it

1 Answers1

0

There is an way to do both in a single line command, using mysql and mail commands as follows,

mysql -D databasename -u username -p password -e "update xxx set xxxx= 1111 where yyy=111"|mail -s subject your@mail.com

Here is the explanation of above command:

For mysql command

-D [database] : this option is used for selecting database at MySQL.

-u [username] : this option is used for selecting username at MySQL.

-p [password] : this option is used for selecting password at MySQL.

For mail command

-s [subject] : this option is used for subject string.

Reference for mail command.

Community
  • 1
  • 1
Arnab Nandy
  • 6,472
  • 5
  • 44
  • 50