Hello, friends. In this short post, you will learn how to export from MariaDB table to Calc / Excel. It is simple, but this trick, especially in enterprise environments, can be very useful.
Although the process is not as automatic as you might think, the fact is that it is simple and can save you a headache or two. Let’s go.
How to export from MariaDB table to Calc / Excel?
I imagine that you already have a database with one (or several) tables. If not, then you have to create one.
In my case, I didn’t have a table at hand and I used a MySQL data generator. You can use anyone.
What we have to do is to set up a query within the table and export it to a form that we can import in either Calc or Excel. This statement can be any statement that returns results.
So, first generate the results you want. In my case, it is a simple SELECT, but I repeat it can be whatever you want.
sudo mysql -u root -p
And then,
use Sample;
Then:
SELECT * FROM Student;
In my case, I got
Now that you know which statement to use, exit from the console
exit;
And from the system, execute this command
sudo mysql -u root -p [database] -e "[query]" -B > output.csv
In my case, I executed the following
sudo mysql -u root -p Sample -e "Select * from Student" -B > export.csv
Once you enter the password, the process will be done.
When you have the file ready, then import it with Calc.
Look at the result
As you can see, the result is excellent.
Conclusion
Calc is a great alternative to Excel, but occasionally, we need data from it that comes from MySQL or MariaDB. Now you know how to do it in a quick and easy way.