Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
kshvakov committed Jan 27, 2017
1 parent e92a54d commit 68535b9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
11 changes: 6 additions & 5 deletions README.md
@@ -1,6 +1,6 @@
# ClickHouse
# ClickHouse [![Build Status](https://travis-ci.org/kshvakov/clickhouse.svg?branch=master)](https://travis-ci.org/kshvakov/clickhouse) [![Go Report Card](https://goreportcard.com/badge/github.com/kshvakov/clickhouse)](https://goreportcard.com/report/github.com/kshvakov/clickhouse) [![Coverage Status](https://coveralls.io/repos/github/kshvakov/clickhouse/badge.svg?branch=master)](https://coveralls.io/github/kshvakov/clickhouse?branch=master)

Golang SQL database driver for [Yandex ClickHouse](https://clickhouse.yandex/) [![Build Status](https://travis-ci.org/kshvakov/clickhouse.svg?branch=master)](https://travis-ci.org/kshvakov/clickhouse) [![Go Report Card](https://goreportcard.com/badge/github.com/kshvakov/clickhouse)](https://goreportcard.com/report/github.com/kshvakov/clickhouse) [![Coverage Status](https://coveralls.io/repos/github/kshvakov/clickhouse/badge.svg?branch=master)](https://coveralls.io/github/kshvakov/clickhouse?branch=master)
Golang SQL database driver for [Yandex ClickHouse](https://clickhouse.yandex/)

## Key features

Expand All @@ -10,8 +10,9 @@ Golang SQL database driver for [Yandex ClickHouse](https://clickhouse.yandex/) [

## DSN

* read_timeout/write_timeout - timeout in second
* username/password - auth credentials
* database - select the current default database
* read_timeout/write_timeout - timeout in second
* alt_hosts - comma separated list of single address host for load-balancing
* debug - enable debug output (boolean value)

Expand All @@ -31,7 +32,7 @@ Golang SQL database driver for [Yandex ClickHouse](https://clickhouse.yandex/) [

example:
```
tcp://host1:9000?timeout=60&username=user&password=qwerty&alt_hosts=host2:9000,host3:9000
tcp://host1:9000?username=user&password=qwerty&database=clicks&read_timeout=10&write_timeout=20&alt_hosts=host2:9000,host3:9000
```


Expand All @@ -54,7 +55,7 @@ import (
)

func main() {
connect, err := sql.Open("clickhouse", "tcp://127.0.0.1:9000?username=&compress=true&debug=true")
connect, err := sql.Open("clickhouse", "tcp://127.0.0.1:9000?debug=true")
if err != nil {
log.Fatal(err)
}
Expand Down
27 changes: 27 additions & 0 deletions clickhouse_naive_test.go
@@ -0,0 +1,27 @@
package clickhouse

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
)

func Test_Naive_Result(t *testing.T) {
var result result
if _, err := result.LastInsertId(); assert.Error(t, err) {
if rows, err := result.RowsAffected(); assert.Error(t, err) {
assert.Equal(t, int64(0), rows)
}
}
}

func Test_Naive_Exception(t *testing.T) {
exception := Exception{
Code: 42,
Message: "test",
}
if assert.Implements(t, (*error)(nil), &exception) {
assert.Equal(t, fmt.Sprintf("code: %d, message: %s", exception.Code, exception.Message), exception.Error())
}
}
6 changes: 4 additions & 2 deletions result.go
@@ -1,6 +1,8 @@
package clickhouse

import "errors"

type result struct{}

func (*result) LastInsertId() (int64, error) { return 0, nil }
func (*result) RowsAffected() (int64, error) { return 0, nil }
func (*result) LastInsertId() (int64, error) { return 0, errors.New("LastInsertId is not supported") }
func (*result) RowsAffected() (int64, error) { return 0, errors.New("RowsAffected is not supported") }

0 comments on commit 68535b9

Please sign in to comment.