diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02d5e11..dcd4be4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,3 +91,11 @@ jobs: run: | cd applications/sveltekit pnpm install + + application-mydata: + runs-on: ubuntu-latest + steps: + - name: Build and run sample + run: | + cd applications/mydata + make && ./dist/mydata exp -h diff --git a/applications/mydata/Makefile b/applications/mydata/Makefile index 58f2ea3..f324e31 100644 --- a/applications/mydata/Makefile +++ b/applications/mydata/Makefile @@ -23,11 +23,7 @@ LDFLAGS += -X "$(REPO)/internal/version.GitHash=$(GITHASH)" LDFLAGS += -X "$(REPO)/internal/version.GitBranch=$(GITREF)" LDFLAGS += -X "$(REPO)/internal/version.GoVersion=$(GOVER)" -all: gen conv mydata +all: mydata mydata: - CGO_CFLAGS=-I$(IBM_DB_HOME)/include CGO_LDFLAGS=-L$(IBM_DB_HOME)/lib $(GOBUILD) -ldflags '$(LDFLAGS)' -o ./dist/mydata main.go -gen: - CGO_CFLAGS=-I$(IBM_DB_HOME)/include CGO_LDFLAGS=-L$(IBM_DB_HOME)/lib $(GOBUILD) -ldflags '$(LDFLAGS)' -o ./dist/gen cmd/other/genschema/gen.go -conv: - CGO_CFLAGS=-I$(IBM_DB_HOME)/include CGO_LDFLAGS=-L$(IBM_DB_HOME)/lib $(GOBUILD) -ldflags '$(LDFLAGS)' -o ./dist/conv cmd/other/conv/conv.go + $(GOBUILD) -ldflags '$(LDFLAGS)' -o ./dist/mydata main.go diff --git a/applications/mydata/README.md b/applications/mydata/README.md index 5c90334..deaa0ba 100644 --- a/applications/mydata/README.md +++ b/applications/mydata/README.md @@ -1,9 +1,9 @@ # A Fast and Flexible export data from remote mysql server -# how to use +### how to use `go run main.go` or you can `go build -o mydata main.go && ./mydata -h` -# cmd help +### cmd help ```text Usage: @@ -23,4 +23,40 @@ Flags: -h, --help help for mydata Use "mydata [command] --help" for more information about a command. -``` \ No newline at end of file +``` + +### How to export data +pls type help: +`./mydata exp -h` + +```text +Export data from remote database server + +Usage: + mydata export [flags] + +Aliases: + export, exp + +Flags: + -a, --addr string mysql database addr, format: ip:port + -u, --username string username for connect database + -p, --password string password for connect database + -D, --dbname string default database name + -e, --query-sql string select sql + -o, --output string output filename + --fields-terminated string fields terminated (default ",") + --fields-enclosed string fields enclosed + --fields-escaped string fields escaped (default "\\") + --lines-terminated string lines terminated (default "\n") + --enclosed-optionally fields enclosed optionally + --params string connection Params (default "timeout=3s") + --buf-size int buf size for write outfile (default 32768) + --concurrency int concurrency number (default 5) + --not-merge merge chunks to one file +``` +### example +export data by `select * from bigdata` from 127.0.0.1 +```shell +./mydata exp -a 127.0.0.1:3306 -u username@tenant#clustername:clusterid -p xxx -D test -e "select * from bigdata" -o bigdata +```