Run a query against MySQL and send its output as CSV by email
1.4K
This simple docker image runs a Query against a MySQL server and send its output as CSV by email.
To accomplish this, some variables must be set.
Every configuration is done via environment variables. There are variables to:
REPORT_NAME: name of attachment send by email. If not defined, defaults to report.MAIL_SUBJECT: subject of email. Defaults to Mail query.MAIL_BODY: body of email. Defaults to Results are attached, have a nice day!.Mysql variables are self explanatory:
DB_HOSTDB_USERDB_PASSWORDDB_NAMEQUERY: this variable is an SQL query. For example: select * from products.This variables are also self explanatory:
MAIL_FROMMAIL_TOSMTP_HOSTSMTP_USERNAMESMTP_PASSWORDSMTP_PORT: defaults to 25SMTP username and password can be ignored and they will not be used.
SMTP tls/ssl connections are not implemented. It's not complicated to add those configurations, but in our environment is not needed because of a relay server.
docker run --rm \
-e DB_HOST=127.0.0.1 \
-e DB_USER=root \
-e DB_PASSWORD=root \
-e DB_NAME=dbname \
-e QUERY="select * from products" \
-e [email protected] \
-e [email protected] \
-e SMTP_HOST=smtp.example.com \
--network host \
mikroways/sql2csv-by-mail
Content type
Image
Digest
Size
372 MB
Last updated
about 6 years ago
docker pull mikroways/sql2csv-by-mail