diff --git a/.gitignore b/.gitignore index 3025d68..1899638 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ vendor/ glide build/ + +.idea/ +*.db* +*.csv + +dist/ \ No newline at end of file diff --git a/Gopkg.lock b/Gopkg.lock new file mode 100644 index 0000000..ef2ec1b --- /dev/null +++ b/Gopkg.lock @@ -0,0 +1,50 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + digest = "1:fe6dc28135d1c569a8c07f1cf20e7831772e6982dc861e923c4558c320811207" + name = "github.com/dinedal/textql" + packages = [ + "inputs", + "sqlparser", + "sqlparser/sqltypes", + ] + pruneopts = "UT" + revision = "1785cd353c68aa34f97627143b9c2908dfd4ea04" + version = "2.0.3" + +[[projects]] + digest = "1:e2d1d410fb367567c2b53ed9e2d719d3c1f0891397bb2fa49afd747cfbf1e8e4" + name = "github.com/mattn/go-runewidth" + packages = ["."] + pruneopts = "UT" + revision = "9e777a8366cce605130a531d2cd6363d07ad7317" + version = "v0.0.2" + +[[projects]] + digest = "1:f4d329a16a6f1a7f694148ec7531f85d62cfa6a79bb8200ca612667e40d09923" + name = "github.com/mattn/go-sqlite3" + packages = ["."] + pruneopts = "UT" + revision = "590d44c02bca83987d23f6eab75e6d0ddf95f644" + version = "v1.13.0" + +[[projects]] + branch = "master" + digest = "1:4daa045e1e1f3e23f4b07db6880cdf9f259dab65312dfe244a878e6070faaf77" + name = "github.com/olekukonko/tablewriter" + packages = ["."] + pruneopts = "UT" + revision = "d4647c9c7a84d847478d890b816b7d8b62b0b279" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + input-imports = [ + "github.com/dinedal/textql/inputs", + "github.com/dinedal/textql/sqlparser", + "github.com/mattn/go-sqlite3", + "github.com/olekukonko/tablewriter", + ] + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml new file mode 100644 index 0000000..a1e686b --- /dev/null +++ b/Gopkg.toml @@ -0,0 +1,38 @@ +# Gopkg.toml example +# +# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" +# +# [prune] +# non-go = false +# go-tests = true +# unused-packages = true + + +[[constraint]] + name = "github.com/mattn/go-sqlite3" + version = "1.10.0" + +[[constraint]] + branch = "master" + name = "github.com/olekukonko/tablewriter" + +[prune] + go-tests = true + unused-packages = true diff --git a/Readme.md b/Readme.md index 80575f3..7fcf6d1 100644 --- a/Readme.md +++ b/Readme.md @@ -1,12 +1,12 @@ -# TextQL +# TextQL practicing PRS -[![Build Status](https://travis-ci.org/dinedal/textql.svg)](https://travis-ci.org/dinedal/textql) [![Go Report Card](http://goreportcard.com/badge/dinedal/textql)](http://goreportcard.com/report/dinedal/textql) +[![Build Status](https://travis-ci.org/OneCloudInc/textql.svg)](https://travis-ci.org/OneCloudInc/textql) [![Go Report Card](http://goreportcard.com/badge/OneCloudInc/textql)](http://goreportcard.com/report/OneCloudInc/textql) Allows you to easily execute SQL against structured text like CSV or TSV. Example session: -![textql_usage_session](https://raw.github.com/dinedal/textql/master/textql_usage.gif) +![textql_usage_session](https://raw.github.com/OneCloudInc/textql/master/textql_usage.gif) ## Major changes! @@ -66,7 +66,7 @@ brew install textql **Build from source** ```bash -go get -u github.com/dinedal/textql/... +go get -u github.com/OneCloudInc/textql/... ``` ## Docker diff --git a/TODO.txt b/TODO.txt index 3f426e8..0585dcc 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,28 +1,28 @@ Install is really complex with vitess dep. Find a way to fix it? -~ go get -u github.com/dinedal/textql/... -# github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_int.go:7: MyType redeclared in this block - previous declaration at go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_custom.go:7 -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_map.go:7: MyType redeclared in this block - previous declaration at go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_int.go:7 -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_mixed.go:11: MyType redeclared in this block - previous declaration at go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_map.go:7 -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_private.go:7: MyType redeclared in this block - previous declaration at go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_mixed.go:11 -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_ptr.go:7: MyType redeclared in this block - previous declaration at go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_private.go:7 -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_simple.go:9: MyType redeclared in this block - previous declaration at go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_ptr.go:7 -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_slice.go:7: MyType redeclared in this block - previous declaration at go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_simple.go:9 -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_tag.go:7: MyType redeclared in this block - previous declaration at go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_slice.go:7 -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/output_int.go:29: (*MyType).UnmarshalBson redeclared in this block - previous declaration at go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/output_custom.go:42 -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/output_map.go:18: (*MyType).MarshalBson redeclared in this block - previous declaration at go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/output_custom.go:19 -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/data/test/bson_test/output_map.go:18: too many errors +~ go get -u github.com/OneCloudInc/textql/... +# github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_int.go:7: MyType redeclared in this block + previous declaration at go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_custom.go:7 +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_map.go:7: MyType redeclared in this block + previous declaration at go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_int.go:7 +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_mixed.go:11: MyType redeclared in this block + previous declaration at go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_map.go:7 +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_private.go:7: MyType redeclared in this block + previous declaration at go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_mixed.go:11 +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_ptr.go:7: MyType redeclared in this block + previous declaration at go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_private.go:7 +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_simple.go:9: MyType redeclared in this block + previous declaration at go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_ptr.go:7 +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_slice.go:7: MyType redeclared in this block + previous declaration at go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_simple.go:9 +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_tag.go:7: MyType redeclared in this block + previous declaration at go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/input_slice.go:7 +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/output_int.go:29: (*MyType).UnmarshalBson redeclared in this block + previous declaration at go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/output_custom.go:42 +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/output_map.go:18: (*MyType).MarshalBson redeclared in this block + previous declaration at go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/output_custom.go:19 +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/data/test/bson_test/output_map.go:18: too many errors # pkg-config --cflags gomysql Package gomysql was not found in the pkg-config search path. Perhaps you should add the directory containing `gomysql.pc' @@ -47,15 +47,15 @@ Perhaps you should add the directory containing `gomysql.pc' to the PKG_CONFIG_PATH environment variable No package 'gomysql' found pkg-config: exit status 1 -# github.com/dinedal/textql/vendor/github.com/youtube/vitess/go/stats/influxdbbackend -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/go/stats/influxdbbackend/influxdb_backend.go:40: undefined: client.ClientConfig -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/go/stats/influxdbbackend/influxdb_backend.go:60: undefined: client.Series -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/go/stats/influxdbbackend/influxdb_backend.go:62: undefined: client.Series -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/go/stats/influxdbbackend/influxdb_backend.go:73: backend.client.WriteSeries undefined (type *client.Client has no field or method WriteSeries) -# github.com/dinedal/textql/vendor/github.com/youtube/vitess/go/terminal -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/go/terminal/tty.go:16: undefined: syscall.TCGETS -# github.com/dinedal/textql/vendor/github.com/youtube/vitess/third_party/go/launchpad.net/gozk/zookeeper -go/src/github.com/dinedal/textql/vendor/github.com/youtube/vitess/third_party/go/launchpad.net/gozk/zookeeper/zk.go:15:10: fatal error: 'zookeeper.h' file not found +# github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/go/stats/influxdbbackend +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/go/stats/influxdbbackend/influxdb_backend.go:40: undefined: client.ClientConfig +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/go/stats/influxdbbackend/influxdb_backend.go:60: undefined: client.Series +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/go/stats/influxdbbackend/influxdb_backend.go:62: undefined: client.Series +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/go/stats/influxdbbackend/influxdb_backend.go:73: backend.client.WriteSeries undefined (type *client.Client has no field or method WriteSeries) +# github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/go/terminal +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/go/terminal/tty.go:16: undefined: syscall.TCGETS +# github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/third_party/go/launchpad.net/gozk/zookeeper +go/src/github.com/OneCloudInc/textql/vendor/github.com/youtube/vitess/third_party/go/launchpad.net/gozk/zookeeper/zk.go:15:10: fatal error: 'zookeeper.h' file not found #include ^ 1 error generated. @@ -67,28 +67,28 @@ Fix all the below: Gofmt formats Go programs. We run gofmt -s on your code, where -s is for the "simplify" command -/github.com/dinedal/textql/outputs/csv.go -/github.com/dinedal/textql/storage/sqlite_test.go +/github.com/OneCloudInc/textql/outputs/csv.go +/github.com/OneCloudInc/textql/storage/sqlite_test.go Gocyclo calculates cyclomatic complexities of functions in Go source code. The cyclomatic complexity of a function is calculated according to the following rules: 1 is the base complexity of a function +1 for each 'if', 'for', 'case', '&&' or '||' -/github.com/dinedal/textql/cmd/textql.go -Line 106: 24 main main repos/src/github.com/dinedal/textql/cmd/textql.go:106:1 -/github.com/dinedal/textql/sqlparser/parsed_query.go -Line 53: 18 sqlparser EncodeValue repos/src/github.com/dinedal/textql/sqlparser/parsed_query.go:53:1 -/github.com/dinedal/textql/sqlparser/sql.go -/github.com/dinedal/textql/sqlparser/token.go -Line 141: 31 sqlparser (*Tokenizer).Scan repos/src/github.com/dinedal/textql/sqlparser/token.go:141:1 -Line 297: 16 sqlparser (*Tokenizer).scanNumber repos/src/github.com/dinedal/textql/sqlparser/token.go:297:1 -/github.com/dinedal/textql/sqlparser/tracked_buffer.go -Line 40: 18 sqlparser (*TrackedBuffer).Myprintf repos/src/github.com/dinedal/textql/sqlparser/tracked_buffer.go:40:1 +/github.com/OneCloudInc/textql/cmd/textql.go +Line 106: 24 main main repos/src/github.com/OneCloudInc/textql/cmd/textql.go:106:1 +/github.com/OneCloudInc/textql/sqlparser/parsed_query.go +Line 53: 18 sqlparser EncodeValue repos/src/github.com/OneCloudInc/textql/sqlparser/parsed_query.go:53:1 +/github.com/OneCloudInc/textql/sqlparser/sql.go +/github.com/OneCloudInc/textql/sqlparser/token.go +Line 141: 31 sqlparser (*Tokenizer).Scan repos/src/github.com/OneCloudInc/textql/sqlparser/token.go:141:1 +Line 297: 16 sqlparser (*Tokenizer).scanNumber repos/src/github.com/OneCloudInc/textql/sqlparser/token.go:297:1 +/github.com/OneCloudInc/textql/sqlparser/tracked_buffer.go +Line 40: 18 sqlparser (*TrackedBuffer).Myprintf repos/src/github.com/OneCloudInc/textql/sqlparser/tracked_buffer.go:40:1 gofmt 89% golint 10% Golint is a linter for Go source code. -/github.com/dinedal/textql/cmd/textql.go +/github.com/OneCloudInc/textql/cmd/textql.go Line 18: exported type CommandLineOptions should have comment or be unexported Line 32: exported var VERSION should have comment or be unexported Line 34: exported function NewCommandLineOptions should have comment or be unexported @@ -117,7 +117,7 @@ Line 92: receiver name should be a reflection of its identity; don't use generic Line 96: exported method CommandLineOptions.Usage should have comment or be unexported Line 96: receiver name should be a reflection of its identity; don't use generic names such as "me", "this", or "self" Line 133: can probably use "var inputSources []string" instead -/github.com/dinedal/textql/inputs/csv.go +/github.com/OneCloudInc/textql/inputs/csv.go Line 21: exported type CSVInputOptions should have comment or be unexported Line 27: exported function NewCSVInput should have comment or be unexported Line 27: exported func NewCSVInput returns unexported type *inputs.csvInput, which can be annoying to use @@ -126,19 +126,19 @@ Line 53: receiver name should be a reflection of its identity; don't use generic Line 57: receiver name should be a reflection of its identity; don't use generic names such as "me", "this", or "self" Line 84: receiver name should be a reflection of its identity; don't use generic names such as "me", "this", or "self" Line 106: receiver name should be a reflection of its identity; don't use generic names such as "me", "this", or "self" -/github.com/dinedal/textql/inputs/input.go +/github.com/OneCloudInc/textql/inputs/input.go Line 3: exported type Input should have comment or be unexported -/github.com/dinedal/textql/outputs/csv.go +/github.com/OneCloudInc/textql/outputs/csv.go Line 18: exported type CSVOutputOptions should have comment or be unexported Line 24: exported function NewCSVOutput should have comment or be unexported Line 24: exported func NewCSVOutput returns unexported type *outputs.csvOutput, which can be annoying to use Line 35: receiver name should be a reflection of its identity; don't use generic names such as "me", "this", or "self" Line 53: should omit 2nd value from range; this loop is equivalent to `for i := range ...` -/github.com/dinedal/textql/outputs/output.go +/github.com/OneCloudInc/textql/outputs/output.go Line 5: exported type Output should have comment or be unexported -/github.com/dinedal/textql/sqlparser/analyzer.go +/github.com/OneCloudInc/textql/sqlparser/analyzer.go Line 50: comment on exported function HasINClause should be of the form "HasINClause ..." -/github.com/dinedal/textql/sqlparser/ast.go +/github.com/OneCloudInc/textql/sqlparser/ast.go Line 56: exported method Union.IStatement should have comment or be unexported Line 57: exported method Select.IStatement should have comment or be unexported Line 58: exported method Insert.IStatement should have comment or be unexported @@ -313,7 +313,7 @@ Line 965: exported method Subquery.IRowTuple should have comment or be unexporte Line 970: exported method UpdateExprs.Format should have comment or be unexported Line 984: exported method UpdateExpr.Format should have comment or be unexported Line 991: exported method OnDup.Format should have comment or be unexported -/github.com/dinedal/textql/sqlparser/parsed_query.go +/github.com/OneCloudInc/textql/sqlparser/parsed_query.go Line 20: exported type ParsedQuery should have comment or be unexported Line 25: exported type EncoderFunc should have comment or be unexported Line 27: exported method ParsedQuery.GenerateQuery should have comment or be unexported @@ -322,8 +322,8 @@ Line 53: exported function EncodeValue should have comment or be unexported Line 102: exported type TupleEqualityList should have comment or be unexported Line 107: exported method TupleEqualityList.Encode should have comment or be unexported Line 156: exported function FetchBindVar should have comment or be unexported -/github.com/dinedal/textql/sqlparser/sql.go -/github.com/dinedal/textql/sqlparser/token.go +/github.com/OneCloudInc/textql/sqlparser/sql.go +/github.com/OneCloudInc/textql/sqlparser/token.go Line 15: exported const EOFCHAR should have comment or be unexported Line 172: if block ends with a return statement, so drop this else and outdent its block Line 190: if block ends with a return statement, so drop this else and outdent its block @@ -331,11 +331,11 @@ Line 214: if block ends with a return statement, so drop this else and outdent i Line 221: if block ends with a return statement, so drop this else and outdent its block Line 249: var keywordId should be keywordID Line 417: exported method Tokenizer.ConsumeNext should have comment or be unexported -/github.com/dinedal/textql/sqlparser/tracked_buffer.go +/github.com/OneCloudInc/textql/sqlparser/tracked_buffer.go Line 25: exported function NewTrackedBuffer should have comment or be unexported Line 101: exported method TrackedBuffer.ParsedQuery should have comment or be unexported Line 105: exported method TrackedBuffer.HasBindVars should have comment or be unexported -/github.com/dinedal/textql/storage/sqlite.go +/github.com/OneCloudInc/textql/storage/sqlite.go Line 20: struct field connId should be connID Line 24: exported type SQLite3Options should have comment or be unexported Line 27: should omit type []*sqlite3.SQLiteConn from declaration of var sqlite3conn; it will be inferred from the right-hand side @@ -353,14 +353,14 @@ Line 184: receiver name should be a reflection of its identity; don't use generi Line 199: receiver name should be a reflection of its identity; don't use generic names such as "me", "this", or "self" Line 207: var backupConnId should be backupConnID Line 234: receiver name should be a reflection of its identity; don't use generic names such as "me", "this", or "self" -/github.com/dinedal/textql/storage/sqlite_test.go +/github.com/OneCloudInc/textql/storage/sqlite_test.go Line 188: should omit 2nd value from range; this loop is equivalent to `for i := range ...` -/github.com/dinedal/textql/storage/storage.go +/github.com/OneCloudInc/textql/storage/storage.go Line 9: exported type Storage should have comment or be unexported -/github.com/dinedal/textql/test_util/test_util.go +/github.com/OneCloudInc/textql/test_util/test_util.go Line 1: don't use an underscore in package name Line 8: exported function OpenFileFromString should have comment or be unexported -/github.com/dinedal/textql/util/file_helpers.go +/github.com/OneCloudInc/textql/util/file_helpers.go Line 12: exported function IsPathDir should have comment or be unexported Line 30: exported function OpenFileOrStdDev should have comment or be unexported Line 65: exported function CleanPath should have comment or be unexported @@ -369,5 +369,5 @@ Line 102: exported function IsThereDataOnStdin should have comment or be unexpor Line 111: if block ends with a return statement, so drop this else and outdent its block Line 116: exported function AllFilesInDirectory should have comment or be unexported Line 119: can probably use "var result []string" instead -/github.com/dinedal/textql/util/seperator_helpers.go +/github.com/OneCloudInc/textql/util/seperator_helpers.go Line 10: exported function DetermineSeparator should have comment or be unexported diff --git a/binaries/textql.exe b/binaries/textql.exe new file mode 100644 index 0000000..1859fd6 Binary files /dev/null and b/binaries/textql.exe differ diff --git a/binaries/textql_linux b/binaries/textql_linux new file mode 100755 index 0000000..2dbf4ec Binary files /dev/null and b/binaries/textql_linux differ diff --git a/binaries/textql_macos b/binaries/textql_macos new file mode 100755 index 0000000..453c7f0 Binary files /dev/null and b/binaries/textql_macos differ diff --git a/inputs/csv_test.go b/inputs/csv_test.go index b84ae5f..0128820 100644 --- a/inputs/csv_test.go +++ b/inputs/csv_test.go @@ -7,7 +7,7 @@ import ( "reflect" "testing" - "github.com/dinedal/textql/test_util" + "github.com/OneCloudInc/textql/test_util" ) var ( diff --git a/sqlparser/analyzer.go b/sqlparser/analyzer.go index 1458ff5..6fd56ba 100644 --- a/sqlparser/analyzer.go +++ b/sqlparser/analyzer.go @@ -9,7 +9,7 @@ package sqlparser import ( "fmt" - "github.com/dinedal/textql/sqlparser/sqltypes" + "github.com/OneCloudInc/textql/sqlparser/sqltypes" ) // GetTableName returns the table name from the SimpleTableExpr diff --git a/sqlparser/ast.go b/sqlparser/ast.go index 8f02c5e..5f99079 100644 --- a/sqlparser/ast.go +++ b/sqlparser/ast.go @@ -9,7 +9,7 @@ import ( "fmt" "strconv" - "github.com/dinedal/textql/sqlparser/sqltypes" + "github.com/OneCloudInc/textql/sqlparser/sqltypes" ) // Instructions for creating new types: If a type diff --git a/sqlparser/parsed_query.go b/sqlparser/parsed_query.go index 06c9382..9e7aad2 100644 --- a/sqlparser/parsed_query.go +++ b/sqlparser/parsed_query.go @@ -10,7 +10,7 @@ import ( "errors" "fmt" - "github.com/dinedal/textql/sqlparser/sqltypes" + "github.com/OneCloudInc/textql/sqlparser/sqltypes" ) type bindLocation struct { diff --git a/sqlparser/token.go b/sqlparser/token.go index 19ef0ac..ec495cc 100644 --- a/sqlparser/token.go +++ b/sqlparser/token.go @@ -9,7 +9,7 @@ import ( "fmt" "strings" - "github.com/dinedal/textql/sqlparser/sqltypes" + "github.com/OneCloudInc/textql/sqlparser/sqltypes" ) const EOFCHAR = 0x100 diff --git a/storage/sqlite.go b/storage/sqlite.go index 2939adf..c58aba9 100644 --- a/storage/sqlite.go +++ b/storage/sqlite.go @@ -24,7 +24,9 @@ type SQLite3Storage struct { } // SQLite3Options are options passed into SQLite3 connection as needed. -type SQLite3Options struct{} +type SQLite3Options struct{ + DataSource string +} var ( sqlite3conn = []*sqlite3.SQLiteConn{} @@ -59,7 +61,9 @@ func init() { // NewSQLite3StorageWithDefaults returns a SQLite3Storage with the default options. func NewSQLite3StorageWithDefaults() *SQLite3Storage { - return NewSQLite3Storage(&SQLite3Options{}) + return NewSQLite3Storage(&SQLite3Options{ + DataSource: "localdb.db", + }) } // NewSQLite3Storage returns a SQLite3Storage with the SQLite3Options provided applied. @@ -74,7 +78,7 @@ func NewSQLite3Storage(opts *SQLite3Options) *SQLite3Storage { } func (sqlite3Storage *SQLite3Storage) open() { - db, err := sql.Open("sqlite3_textql", ":memory:") + db, err := sql.Open("sqlite3_textql", sqlite3Storage.options.DataSource) if err != nil { log.Fatalln(err) diff --git a/storage/sqlite_test.go b/storage/sqlite_test.go index 8e646ba..74c47fd 100644 --- a/storage/sqlite_test.go +++ b/storage/sqlite_test.go @@ -7,8 +7,8 @@ import ( "os/exec" "testing" - "github.com/dinedal/textql/inputs" - "github.com/dinedal/textql/test_util" + "github.com/OneCloudInc/textql/inputs" + "github.com/OneCloudInc/textql/test_util" ) var ( diff --git a/storage/storage.go b/storage/storage.go index d73776e..6e1f26e 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -3,7 +3,7 @@ package storage import ( "database/sql" - "github.com/dinedal/textql/inputs" + "github.com/OneCloudInc/textql/inputs" ) // Storage implentors are expected to be SQL capable engines. diff --git a/textql/main.go b/textql/main.go index 4d6a7ea..ab44c19 100644 --- a/textql/main.go +++ b/textql/main.go @@ -9,10 +9,10 @@ import ( "os/exec" "strings" - "github.com/dinedal/textql/inputs" - "github.com/dinedal/textql/outputs" - "github.com/dinedal/textql/storage" - "github.com/dinedal/textql/util" + "github.com/OneCloudInc/textql/inputs" + "github.com/OneCloudInc/textql/outputs" + "github.com/OneCloudInc/textql/storage" + "github.com/OneCloudInc/textql/util" ) type commandLineOptions struct { diff --git a/util/file_helpers.go b/util/file_helpers.go index 1781926..8eedc1a 100644 --- a/util/file_helpers.go +++ b/util/file_helpers.go @@ -69,12 +69,12 @@ func CleanPath(path string) string { return "" } - usr, err := user.Current() - if err != nil { - log.Fatalln(err) - } - if len(path) > 1 && path[:2] == "~/" { + usr, err := user.Current() + if err != nil { + log.Fatalln(err) + } + dir := usr.HomeDir + "/" result = strings.Replace(path, "~/", dir, 1) } else {