{"id":20207767,"url":"https://github.com/exasol/exasol-driver-go","last_synced_at":"2025-04-10T12:43:24.153Z","repository":{"id":40386789,"uuid":"363243632","full_name":"exasol/exasol-driver-go","owner":"exasol","description":"Exasol SQL driver for Golang","archived":false,"fork":false,"pushed_at":"2025-04-07T09:24:46.000Z","size":243,"stargazers_count":9,"open_issues_count":7,"forks_count":3,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-07T09:28:04.454Z","etag":null,"topics":["database","driver","exasol","exasol-integration","go","golang","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exasol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-30T19:48:39.000Z","updated_at":"2025-02-19T13:01:25.000Z","dependencies_parsed_at":"2024-03-12T19:39:45.931Z","dependency_job_id":"13fcd8d1-73cd-4b71-bba5-44e5a83fc43a","html_url":"https://github.com/exasol/exasol-driver-go","commit_stats":{"total_commits":69,"total_committers":10,"mean_commits":6.9,"dds":0.6521739130434783,"last_synced_commit":"587bc2737afb8c2e49241a08df76d36cae2ee7f0"},"previous_names":["nightapes/go-exasol","exasol/go-exasol"],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exasol%2Fexasol-driver-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exasol%2Fexasol-driver-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exasol%2Fexasol-driver-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exasol%2Fexasol-driver-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exasol","download_url":"https://codeload.github.com/exasol/exasol-driver-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217160,"owners_count":21066634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","driver","exasol","exasol-integration","go","golang","sql"],"created_at":"2024-11-14T05:32:00.778Z","updated_at":"2025-04-10T12:43:24.135Z","avatar_url":"https://github.com/exasol.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Exasol Go SQL Driver\n\n[![Build Status](https://github.com/exasol/exasol-driver-go/actions/workflows/ci-build.yml/badge.svg)](https://github.com/exasol/exasol-driver-go/actions/workflows/ci-build.yml)\n[![Go Reference](https://pkg.go.dev/badge/github.com/exasol/exasol-driver-go.svg)](https://pkg.go.dev/github.com/exasol/exasol-driver-go)\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-driver-go\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-driver-go)\n\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-driver-go\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-driver-go)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-driver-go\u0026metric=bugs)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-driver-go)\n[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-driver-go\u0026metric=code_smells)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-driver-go)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-driver-go\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-driver-go)\n\nThis repository contains a Go library for connection to the [Exasol](https://www.exasol.com/) database.\n\nThis library uses the standard Golang [SQL driver interface](https://golang.org/pkg/database/sql/) for easy use.\n\n## Prerequisites\n\nTo use the Exasol Go Driver you need an Exasol database in the latest 7.1 or 8 version. Older versions might work but are not supported.\n\n## Usage\n\n### Create Connection\n\n#### With Exasol Config\n\nWe recommend using the provided builder to build a connection string. The builder ensures all values are escaped properly.\n\n```go\npackage main\n\nimport (\n    \"database/sql\"\n    \"github.com/exasol/exasol-driver-go\"\n)\n\nfunc main() {\n    database, err := sql.Open(\"exasol\", exasol.NewConfig(\"\u003cusername\u003e\", \"\u003cpassword\u003e\").\n                                              Host(\"\u003chost\u003e\").\n                                              Port(8563).\n                                              String())\n    // ...\n}\n```\n\nIf you want to login via [OpenID tokens](https://github.com/exasol/websocket-api/blob/master/docs/commands/loginTokenV3.md) use `exasol.NewConfigWithRefreshToken(\"token\")` or `exasol.NewConfigWithAccessToken(\"token\")`. See the [documentation](https://docs.exasol.com/db/latest/sql/create_user.htm#AuthenticationusingOpenID) about how to configure OpenID authentication in Exasol. OpenID authentication is only supported with Exasol 7.1.x and later.\n\n#### With Exasol DSN\n\nYou can also create a connection replacing the builder with a simple string:\n\n```go\npackage main\n\nimport (\n    \"database/sql\"\n    _ \"github.com/exasol/exasol-driver-go\"\n)\n\nfunc main() {\n    database, err := sql.Open(\"exasol\",\n            \"exa:\u003chost\u003e:\u003cport\u003e;user=\u003cusername\u003e;password=\u003cpassword\u003e\")\n    // ...\n}\n```\n\nIf 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.\n\n### Execute Statement\n\n```go\nresult, err := exasol.Exec(`\n    INSERT INTO CUSTOMERS\n    (NAME, CITY)\n    VALUES('Bob', 'Berlin');`)\n```\n\n### Query Statement\n\n```go\nrows, err := exasol.Query(\"SELECT * FROM CUSTOMERS\")\n```\n\n### Use Prepared Statements\n\n```go\npreparedStatement, err := exasol.Prepare(`\n    INSERT INTO CUSTOMERS\n    (NAME, CITY)\n    VALUES(?, ?)`)\nresult, err = preparedStatement.Exec(\"Bob\", \"Berlin\")\n```\n\n```go\npreparedStatement, err := exasol.Prepare(\"SELECT * FROM CUSTOMERS WHERE NAME = ?\")\nrows, err := preparedStatement.Query(\"Bob\")\n```\n\n### Transaction Commit and Rollback\n\nTo control the transaction state manually, you need to disable autocommit (enabled by default):\n\n```go\ndatabase, err := sql.Open(\"exasol\",\n                \"exa:\u003chost\u003e:\u003cport\u003e;user=\u003cusername\u003e;password=\u003cpassword\u003e;autocommit=0\")\n// or\ndatabase, err := sql.Open(\"exasol\", exasol.NewConfig(\"\u003cusername\u003e\", \"\u003cpassword\u003e\")\n                                          .Port(\u003cport\u003e)\n                                          .Host(\"\u003chost\u003e\")\n                                          .Autocommit(false)\n                                          .String())\n```\n\nAfter that you can begin a transaction:\n\n```go\ntransaction, err := exasol.Begin()\nresult, err := transaction.Exec( ... )\nresult2, err := transaction.Exec( ... )\n```\n\nTo commit a transaction use `Commit()`:\n\n```go\nerr = transaction.Commit()\n```\n\nTo rollback a transaction use `Rollback()`:\n\n```go\nerr = transaction.Rollback()\n```\n\n### Import Local CSV Files\n\nUse the sql driver to load data from one or more CSV files into your Exasol Database. These files must be local to the machine where you execute the `IMPORT` statement.\n\n**Limitations:**\n* Only import of CSV files is supported at the moment, FBV is not supported.\n* The `SECURE` option is not supported at the moment.\n\n```go\nresult, err := exasol.Exec(`\nIMPORT INTO CUSTOMERS FROM LOCAL CSV FILE './testData/data.csv' FILE './testData/data_part2.csv'\n  COLUMN SEPARATOR = ';' \n  ENCODING = 'UTF-8' \n  ROW SEPARATOR = 'LF'\n`)\n```\n\nSee also the [usage notes](https://docs.exasol.com/db/latest/sql/import.htm#UsageNotes) about the `file_src` element for local files of the `IMPORT` statement.\n\n### Connection String\n\nThe golang Driver uses the following URL structure for Exasol:\n\n`exa:\u003chost\u003e[,\u003chost_1\u003e]...[,\u003chost_n\u003e]:\u003cport\u003e[;\u003cprop_1\u003e=\u003cvalue_1\u003e]...[;\u003cprop_n\u003e=\u003cvalue_n\u003e]`\n\nHost-Range-Syntax is supported (e.g. `exasol1..3`). A range like `exasol1..exasol3` is not valid.\n\n#### Supported Driver Properties\n\n| Property                    | Value         | Default     | Description                                     |\n| :-------------------------- | :-----------: | :---------: | :---------------------------------------------- |\n| `autocommit`                |  0=off, 1=on  | `1`         | Switch autocommit on or off.                    |\n| `clientname`                |  string       | `Go client` | Tell the server the application name.           |\n| `clientversion`             |  string       |             | Tell the server the version of the application. |\n| `compression`               |  0=off, 1=on  | `0`         | Switch data compression on or off.              |\n| `encryption`                |  0=off, 1=on  | `1`         | Switch automatic encryption on or off.          |\n| `validateservercertificate` |  0=off, 1=on  | `1`         | TLS certificate verification. Disable it if you want to use a self-signed or invalid certificate (server side). |\n| `certificatefingerprint`    |  string       |             | Expected fingerprint of the server's TLS certificate. See below for details. |\n| `fetchsize`                 | numeric, \u003e0   | `128*1024`  | Amount of data in kB which should be obtained by Exasol during a fetch. The application can run out of memory if the value is too high. |\n| `password`                  |  string       |             | Exasol password.                                |\n| `resultsetmaxrows`          |  numeric      |             | Set the max amount of rows in the result set.   |\n| `schema`                    |  string       |             | Exasol schema name.                             |\n| `user`                      |  string       |             | Exasol username.                                |\n\n#### Configuring TLS\n\nWe 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)`.\n\nThere are two driver properties that control how TLS certificates are verified: `validateservercertificate` and `certificatefingerprint`. You have these three options depending on your setup:\n\n* With `validateservercertificate=1` (or `config.ValidateServerCertificate(true)`) the driver will return an error for any TLS errors (e.g. unknown certificate or invalid hostname).\n\n    Use this when the database has a CA-signed certificate. This is the default behavior.\n* With `validateservercertificate=1;certificatefingerprint=\u003cfingerprint\u003e` (or `config.ValidateServerCertificate(true).CertificateFingerprint(\"\u003cfingerprint\u003e\")`) you can specify the fingerprint (i.e. the SHA256 checksum) of the server's certificate.\n\n    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.\n\n    **Note:** You can find the fingerprint by first specifying an invalid fingerprint and connecting to the database. The error will contain the actual fingerprint.\n* With `validateservercertificate=0` (or `config.ValidateServerCertificate(false)`) the driver will ignore any TLS certificate errors.\n\n    Use this if the server uses a self-signed certificate and you don't know the fingerprint. **This is not recommended.**\n\n### Configure Logging\n\n#### Error Logger\n\nBy default the driver will log warnings and error messages to `stderr`. You can configure a custom error logger with\n\n```go\nlogger.SetLogger(log.New(os.Stderr, \"[exasol] \", log.LstdFlags|log.Lshortfile))\n```\n\n#### Trace Logger\n\nBy default the driver does not log any trace or debug messages. To investigate problems you can configure a custom trace logger with\n\n```go\nlogger.SetTraceLogger(log.New(os.Stderr, \"[exasol-trace] \", log.LstdFlags|log.Lshortfile))\n```\n\nYou can deactivate trace logging with\n\n```go\nlogger.SetTraceLogger(nil)\n```\n\n## Information for Users\n\n* [Examples](examples)\n* [Changelog](doc/changes/changelog.md)\n* [Dependencies](dependencies.md)\n\n## Information for Developers\n\n* [Developer guide](doc/developer_guide.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexasol%2Fexasol-driver-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexasol%2Fexasol-driver-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexasol%2Fexasol-driver-go/lists"}