Skip to content

a command line to query the database and save the result to csv. Currently only postgres and mysql are supported.

License

Notifications You must be signed in to change notification settings

zhangyuan/sql2csv

Repository files navigation

Usage

You can download the executables from the Releases page.

Example

Run a local PostgresSQL instance:

docker-compose up

Open a new termial and run:

export DATABASE_URI="postgresql://localhost/postgres?user=postgres&password=mypassword&sslmode=disable"

go run main.go -q "select * from users" | tee output.csv

# or use the executable on MacOS for example

./sql2csv-amd64-darwin -q "select * from users" | tee output.csv

DATABASE_URI examples

MySQL

export DATABASE_URI=mysql://root:mypassword@tcp(127.0.0.1:3306)/csv

Postgres

export DATABASE_URI="postgresql://localhost/postgres?user=postgres&password=mypassword&sslmode=disable"

MaxCompute (ODPS)

DATABASE_URI="http://ACCESS_KEY_ID:[email protected]/api?project=project_name"

About

a command line to query the database and save the result to csv. Currently only postgres and mysql are supported.

Resources

License

Stars

Watchers

Forks

Packages

No packages published