Skip to content

Commit

Permalink
#103: Added UrlPath parameter (#102)
Browse files Browse the repository at this point in the history
Co-authored-by: Christoph Kuhnke <[email protected]>
Co-authored-by: Christoph Pirkl <[email protected]>
  • Loading branch information
3 people authored Mar 13, 2024
1 parent baadefb commit f987853
Show file tree
Hide file tree
Showing 22 changed files with 294 additions and 134 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/broken_links_checker.yml

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

53 changes: 26 additions & 27 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,49 @@
name: Go
on:
push:
branches:
- main
branches: ["main"]
pull_request:

jobs:
build:
matrix-build:
strategy:
matrix:
go: ["1.20", "1.21"]
db: ["7.1.23", "8.23.0"]
go: ["1.21", "1.22"]
db: ["7.1.25", "8.24.0"]
env:
DEFAULT_GO: "1.21"
DEFAULT_DB: "8.23.0"
DEFAULT_GO: "1.22"
DEFAULT_DB: "8.24.0"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-go-${{ matrix.go }}-db-${{ matrix.db }}
cancel-in-progress: true
name: Build with go version ${{ matrix.go }} and db ${{ matrix.db }}
runs-on: ubuntu-20.04
defaults:
run:
shell: "bash"
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
id: go

- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/cache@v3
- name: Set up Go
id: go
uses: actions/setup-go@v5
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go }}
${{ runner.os }}-go-
- name: Enable testcontainer reuse
run: echo 'testcontainers.reuse.enable=true' > "$HOME/.testcontainers.properties"
go-version: ${{ matrix.go }}
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: latest
version: v1.56.2
skip-pkg-cache: true # Caching already done by actions/cache
skip-build-cache: true

- name: Enable testcontainer reuse
run: echo 'testcontainers.reuse.enable=true' > "$HOME/.testcontainers.properties"

- name: Go build
run: |
go clean
Expand All @@ -71,3 +64,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build:
needs: matrix-build
runs-on: ubuntu-latest
steps:
- run: echo "Build successful"
50 changes: 24 additions & 26 deletions .github/workflows/project-keeper-verify.yml

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

7 changes: 5 additions & 2 deletions .github/workflows/project-keeper.sh

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

2 changes: 1 addition & 1 deletion .project-keeper.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources:
- type: golang
path: go.mod
version: 1.0.4
version: 1.0.5
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.generate.finalModifiers": true,
"source.fixAll": true
"source.organizeImports": "explicit",
"source.generate.finalModifiers": "explicit",
"source.fixAll": "explicit"
},
"go.testTimeout": "240s",
"go.testFlags": ["-p", "1", "-v"],
Expand Down
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To use the Exasol Go Driver you need an Exasol database in the latest 7.1 or 8 v

#### With Exasol Config

We recommend using a provided builder to build a connection string:
We recommend using the provided builder to build a connection string. The builder ensures all values are escaped properly.

```go
package main
Expand All @@ -36,8 +36,8 @@ import (

func main() {
database, err := sql.Open("exasol", exasol.NewConfig("<username>", "<password>").
Port(<port>).
Host("<host>").
Port(8563).
String())
// ...
}
Expand All @@ -47,7 +47,7 @@ If you want to login via [OpenID tokens](https://github.com/exasol/websocket-api

#### With Exasol DSN

There is also a way to build the connection string without the builder:
You can also create a connection replacing the builder with a simple string:

```go
package main
Expand All @@ -64,6 +64,8 @@ func main() {
}
```

If a value in the connection string contains a `;` you need to escape it with `\;`. This ensures that the driver can parse the connection string as expected.

### Execute Statement

```go
Expand Down Expand Up @@ -96,7 +98,7 @@ rows, err := preparedStatement.Query("Bob")

## Transaction Commit and Rollback

To control a transaction state manually, you would need to disable autocommit (enabled by default):
To control the transaction state manually, you need to disable autocommit (enabled by default):

```go
database, err := sql.Open("exasol",
Expand Down Expand Up @@ -137,13 +139,12 @@ Use the sql driver to load data from one or more CSV files into your Exasol Data
* Only import of CSV files is supported at the moment, FBV is not supported.
* The `SECURE` option is not supported at the moment.


```go
result, err := exasol.Exec(`
IMPORT INTO CUSTOMERS FROM LOCAL CSV FILE './testData/data.csv' FILE './testData/data_part2.csv'
COLUMN SEPARATOR = ';'
ENCODING = 'UTF-8'
ROW SEPARATOR = 'LF'
IMPORT INTO CUSTOMERS FROM LOCAL CSV FILE './testData/data.csv' FILE './testData/data_part2.csv'
COLUMN SEPARATOR = ';'
ENCODING = 'UTF-8'
ROW SEPARATOR = 'LF'
`)
```

Expand Down Expand Up @@ -176,7 +177,7 @@ Host-Range-Syntax is supported (e.g. `exasol1..3`). A range like `exasol1..exaso

### Configuring TLS

We recommend to always enable TLS encryption. This is on by default, but you can enable it explicitly via driver property `encryption=1` or `config.Encryption(true)`.
We recommend to always enable TLS encryption. This is on by default, but you can enable it explicitly via driver property `encryption=1` or `config.Encryption(true)`. Please note that starting with version 8, Exasol does not support unencrypted connections anymore, so you can't use `encryption=0` or `config.Encryption(false)`.

There are two driver properties that control how TLS certificates are verified: `validateservercertificate` and `certificatefingerprint`. You have these three options depending on your setup:

Expand All @@ -185,9 +186,9 @@ There are two driver properties that control how TLS certificates are verified:
Use this when the database has a CA-signed certificate. This is the default behavior.
* With `validateservercertificate=1;certificatefingerprint=<fingerprint>` (or `config.ValidateServerCertificate(true).CertificateFingerprint("<fingerprint>")`) you can specify the fingerprint (i.e. the SHA256 checksum) of the server's certificate.

This is useful when the database has a self-signed certificate with invalid hostname but you still want to verify connecting to the corrrect host.
This is useful when the database has a self-signed certificate with invalid hostname but you still want to verify connecting to the correct host.

**Note:** You can find the fingerprint by first specifiying an invalid fingerprint and connecting to the database. The error will contain the actual fingerprint.
**Note:** You can find the fingerprint by first specifying an invalid fingerprint and connecting to the database. The error will contain the actual fingerprint.
* With `validateservercertificate=0` (or `config.ValidateServerCertificate(false)`) the driver will ignore any TLS certificate errors.

Use this if the server uses a self-signed certificate and you don't know the fingerprint. **This is not recommended.**
Expand Down
10 changes: 5 additions & 5 deletions dependencies.md

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

1 change: 1 addition & 0 deletions doc/changes/changelog.md

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

41 changes: 41 additions & 0 deletions doc/changes/changes_1.0.5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Exasol Driver go 1.0.5, released 2024-03-13

Code name: Escape connection string

## Summary

This release supports using `;` in the connection string. When using the builder like this, it will automatically escape the semicolon:

```go
connectionString := exasol.NewConfig("<username>", "<password>").
Host("<host>").
Port(8563).
ClientName("My Client; Version abc").
String()
```

When using the connection string directly, you need to escape `;` with a `\`:

```go
connectionString := `exa:localhost:1234;user=sys;password=exasol;clientname=My Client\; Version abc`
```

Additionally this release also support specifying an URL path when creating the WebSocket connection to the database. This is only required in special situations and should not be used when connecting to an Exasol database.

## Features

* #103: Added support for URL Path when connecting

## Dependency Updates

### Compile Dependency Updates

* Updated `golang:1.20` to `1.21`
* Updated `github.com/gorilla/websocket:v1.5.0` to `v1.5.1`
* Updated `github.com/stretchr/testify:v1.8.4` to `v1.9.0`
* Updated `github.com/exasol/exasol-test-setup-abstraction-server/go-client:v0.3.4` to `v0.3.6`

### Test Dependency Updates

* Updated `go.uber.org/goleak:v1.2.1` to `v1.3.0`
* Updated `golang.org/x/sync:v0.4.0` to `v0.6.0`
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
module github.com/exasol/exasol-driver-go

go 1.20
go 1.21

require (
github.com/exasol/error-reporting-go v0.2.0
github.com/exasol/exasol-test-setup-abstraction-server/go-client v0.3.4
github.com/gorilla/websocket v1.5.0
github.com/stretchr/testify v1.8.4
go.uber.org/goleak v1.2.1
golang.org/x/sync v0.4.0
github.com/exasol/exasol-test-setup-abstraction-server/go-client v0.3.6
github.com/gorilla/websocket v1.5.1
github.com/stretchr/testify v1.9.0
go.uber.org/goleak v1.3.0
golang.org/x/sync v0.6.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/stretchr/objx v0.5.1 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
golang.org/x/net v0.22.0 // indirect
)
Loading

0 comments on commit f987853

Please sign in to comment.