#!/bin/bash

# CREATE USER app@'%' IDENTIFIED BY 'secret';
# GRANT ALL ON test.* TO app@'%';

user=app
password=secret
host=127.0.0.1
port=3306
database=test
client=$(hostname -s)

type -p mariadb >/dev/null
if [ ${?} -eq 0 ] ; then
  CLIENT=mariadb
else
  CLIENT=mysql
fi

while [ 1 ]
do

  ${CLIENT} --user=$user --password=${password} --host=${host} ${database} --port=${port} --execute="INSERT INTO test (data, seq) VALUES (CONCAT('Test data insert from ${client} on ', @@hostname), NEXT VALUE FOR testSq);" 2>&1 | grep -v 'Using a password on the command'
  if [ ${PIPESTATUS[0]} -eq 0 ] ; then
    echo -n '.'
  else
    echo -n '-'
  fi
  # sleep 1
done
