Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ A pre-compiled binary can be downloaded from the [releases](https://github.com/z
### 2) Configure
Copy the `config.toml.sample` file as `config.toml` somewhere and edit the configuration values.

Source (`[db.*]`) and result (`[results.*]`) databases are configured with a driver `type` and a `dsn`:

| type | dsn |
|------|-----|
| `postgres` | `postgres://user:password@host:5432/dbname?sslmode=disable` |
| `mysql` | `user:password@tcp(host:3306)/dbname` |
| `clickhouse` | `tcp://host:9000?username=user&password=password&database=dbname` |

ClickHouse v1 reads credentials and the database from query parameters. The `user@pass` format is not supported.

### 3) Setup tasks
Write your SQL query tasks in `.sql` files in the `goyesql` format (as shown in the examples earlier) and put them in a directory somewhere.

Expand Down
2 changes: 2 additions & 0 deletions cmd/config.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ results_table = "results_%s"

# type = "postgres" dsn = "postgres://user:password@host:5432/dbname?sslmode=disable"
# type = "mysql" dsn = "user:password@tcp(host:3306)/dbname"
# type = "clickhouse" dsn = "tcp://host:9000?username=user&password=url-encoded-password&database=dbname"
# IMPORTANT: clickhouse DSN requires passwords to be urlencoded if they have special characters.

[db.my_db]
type = "mysql"
Expand Down
12 changes: 2 additions & 10 deletions config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,10 @@ max_idle = 10
max_active = 100
connect_timeout = "10s"

# URL-encode ClickHouse query values (e.g. % as %25, + as %2B).
[db.ch_db]
type = "clickhouse"
dsn = "clickhouse://default:@127.0.0.1:9000/default?sslmode=disable"
dsn = "tcp://127.0.0.1:9000?username=default&password=&database=default"
max_idle = 10
max_active = 100
connect_timeout = "10s"
# host = "localhost"
# port = 9000
# db = "default"
# user = "default"
# password = ""
# autocommit = false
# max_active = 100
# max_idle = 100
# connect_timeout = 60
2 changes: 1 addition & 1 deletion internal/dbpool/dbpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func New(mp map[string]Config) (map[string]*sql.DB, error) {
for name, cfg := range mp {
db, err := NewConn(cfg)
if err != nil {
return nil, err
return nil, fmt.Errorf("db %q: %w", name, err)
}

out[name] = db
Expand Down
Loading