DayFR Euro

OctoSQL – To query your JSON, CSV…etc in SQL | Dev tools

Real DB Admin makes real database. Baby DB Admin does CSV. And that's really annoying to manipulate CSV, or even JSON, TSV, Parquet or even text files line by line.

Fortunately, thanks to Lolilol, I discovered a very nice little tool which will allow you to manipulate data files with SQL, as if you were on a real database. This tool is OctoSQL and beyond the classic SELECT * FROM, you will even be able to make joins between your files, even if they are of different types.

To install it, head to Github or directly with brew:

brew install cube2222/octosql/octosql 

Otherwise, it's Go, so it can be compiled like this:

git clone https://github.com/cube2222/octosql cd octosql go install 

And that's it, then there's more. For my tests, I generated some bogus CSVs from this site and then was able to query them in SQL.

The classic SELECT *:

octosql "SELECT * FROM data.csv" 

Then some things a little more complicated:

octosql "SELECT * FROM data.csv WHERE email LIKE '%gov%'" 

And as I told you, we can even do joins like this:

octosql "SELECT * FROM ID.csv LEFT JOIN data.csv ON ID.id = data.id WHERE email LIKE '%.fr%'" 

There is even a plugin system to extend the functionality of the tool. For example, you can install the postgreSQL or MySQL plugin to mix the real database with static data files. So cool, right?

There's even a plugin to generate random data:

octosql plugin install random_data octosql "SELECT * FROM random_data.users" --describe 

The tool is also capable of managing all data streams. This means that you can launch a query on data that arrives in a continuous flow. I will let you test this last part, as for me, I was not able to get it to run.

To discover here!

-

Related News :