In the past few months I found myself busier with moving data here and there, so
much that scripts ending with load(transform(extract()))
have become my bread
and butter — sad life, some say!
Last night I wanted to import a bunch of data stored in SQL Server into a MySQL database, but didn’t want to get my hards dirty with a GUI or PowerShell because, well, PowerShell.
The result was mssqldump, a small utility
– similar to mysqldump
– to export data into TSV.
Usage
mssqldump
does one thing — and hopefully well — run a query against the
database and export the results as TSV to the stdout:
1 2 3 4 5 6 |
|
You can also include headings (column names) with the -c
option:
1 2 3 4 5 6 7 |
|
If you want to print mssqldump
’s version information you can just specify v
or version
as the query parameter:
1 2 |
|
If you want to use mssqldump
simply download the latest release from github
and start dumping data around!
A couple surprises
Building mssqldump
was an experience on its own, as I discovered a couple useful
things:
- Microsoft is killing it lately — I wanted to test this out and was resigned to
spinning up a SQL Server instance on Azure. Turns out a simple
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Password123!' --net host -d --name mssql --rm microsoft/mssql-server-linux
does the trick! - knowing I was developing a CLI tool in Golang, I thought I would need to resort to cobra — wanting to try to simplify things up I instead opted for go-flags, which has way less features but is also less opinionated and faster to setup (cobra is probably overkill for a CLI app with only one command)
Adios!