How to export from MariaDB table to Calc / Excel?

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

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

The MariaDB sentence to export
The MariaDB sentence to export

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
Export from MariaDB table to Calc / Excel
Export from MariaDB table to Calc / Excel

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

Calc with the MariaDB table
Calc with the MariaDB table

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.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook