P
P
pfedorov0310902021-09-29 15:57:10
SQL
pfedorov031090, 2021-09-29 15:57:10

How to create a script to get data from sql database?

Good afternoon!
The task in the following:
There is a database and the rights to it for reading. It is necessary to execute a request to it once a day in automatic mode and upload the result to a file. To do this, there is a virtual machine on Centos. I don't even know how to approach this problem. Google suggests bash scripts. Maybe there is a solution?
Or has someone already done something like this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2021-09-29
@Rsa97

echo "SELECT * FROM \`database\`.\`table\`" | mysql -uUser -pPassword -hHost > /out/file/name

Well, if you need some specific upload format, you will have to write your own script.

A
Akina, 2021-09-29
@Akina

MySQL can dump the result of a query into a file.
MySQL has a built in scheduler.
So we create an Event Procedure that uploads the result of the desired request to a file in the desired format, launch the Event Scheduler ... and that's it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question