Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test #138

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
vendor/
glide
build/

.idea/
*.db*
*.csv

dist/
50 changes: 50 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -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!

Expand Down Expand Up @@ -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
Expand Down
122 changes: 61 additions & 61 deletions TODO.txt

Large diffs are not rendered by default.

Binary file added binaries/textql.exe
Binary file not shown.
Binary file added binaries/textql_linux
Binary file not shown.
Binary file added binaries/textql_macos
Binary file not shown.
2 changes: 1 addition & 1 deletion inputs/csv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"reflect"
"testing"

"github.com/dinedal/textql/test_util"
"github.com/OneCloudInc/textql/test_util"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion sqlparser/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sqlparser/parsed_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"errors"
"fmt"

"github.com/dinedal/textql/sqlparser/sqltypes"
"github.com/OneCloudInc/textql/sqlparser/sqltypes"
)

type bindLocation struct {
Expand Down
2 changes: 1 addition & 1 deletion sqlparser/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"strings"

"github.com/dinedal/textql/sqlparser/sqltypes"
"github.com/OneCloudInc/textql/sqlparser/sqltypes"
)

const EOFCHAR = 0x100
Expand Down
10 changes: 7 additions & 3 deletions storage/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions storage/sqlite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions textql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions util/file_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down