### Configure Trace Logger Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Set a custom trace logger to investigate problems. This example configures logging to standard error with specific flags. ```go logger.SetTraceLogger(log.New(os.Stderr, "[exasol-trace] ", log.LstdFlags|log.Lshortfile)) ``` -------------------------------- ### Execute Prepared INSERT Statement Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Prepares an SQL statement for execution, allowing for parameter binding to prevent SQL injection and improve performance for repeated executions. This example shows preparing an INSERT statement. ```go preparedStatement, err := exasol.Prepare ( "INSERT INTO CUSTOMERS (NAME, CITY) VALUES(?, ?)" ) result, err = preparedStatement.Exec("Bob", "Berlin") ``` -------------------------------- ### Set Custom Error Logger Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Configure a custom error logger for the Exasol driver. By default, warnings and errors are logged to stderr. This example shows how to set a logger with specific formatting and file information. ```go logger.SetLogger(log.New(os.Stderr, "[exasol] ", log.LstdFlags|log.Lshortfile)) ``` -------------------------------- ### Error: Scan non-integer float to int64 in Go Source: https://github.com/exasol/exasol-driver-go/blob/main/doc/changes/changes_1.0.9.md This example illustrates a known limitation where attempting to scan a non-integer float (e.g., '1.1') into an int64 variable will still result in an 'invalid syntax' error, even after the fix for large integers. ```go sql: Scan error on column index 0, name "COL": converting driver.Value type string ("1.1") to a int64: invalid syntax ``` -------------------------------- ### Error: Scan large float to int64 in Go (pre-fix) Source: https://github.com/exasol/exasol-driver-go/blob/main/doc/changes/changes_1.0.9.md This example shows the error encountered before the fix in version 1.0.9, where scanning large integer values (represented as floats) into an int64 variable failed with a 'converting driver.Value type float64 ... invalid syntax' error. ```go sql: Scan error on column index 0, name "COL": converting driver.Value type float64 ("1e+08") to a int64: invalid syntax ``` -------------------------------- ### Rollback a Transaction Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Aborts the current transaction and discards all changes made since the transaction began. The database state reverts to what it was before the transaction started. ```go err = transaction.Rollback() ``` -------------------------------- ### Basic Exasol Go SQL Driver Connection Source: https://github.com/exasol/exasol-driver-go/blob/main/doc/changes/changes_0.1.0.md Demonstrates how to open a connection to the Exasol database using the exasol-driver-go library. Ensure you have imported the necessary packages and configured the connection details. ```go package main import ( "database/sql" "github.com/exasol/exasol-driver-go" ) func main() { database, err := sql.Open("exasol", exasol.NewConfig("", "").Port().Host("").String()) ... ``` -------------------------------- ### Create Exasol Connection with Config Builder Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Use the `exasol.NewConfig` builder to construct a connection string with proper escaping for Exasol database credentials and host information. ```go package main import ( "database/sql" "github.com/exasol/exasol-driver-go" ) func main() { database, err := sql.Open("exasol", exasol.NewConfig("", ""). Host(""). Port(8563). String()) // ... } ``` -------------------------------- ### Run Unit and Integration Tests Source: https://github.com/exasol/exasol-driver-go/blob/main/doc/developer_guide.md Execute all tests, including integration tests. Requires Docker and Java. Integration tests rely on exasol-test-setup-abstraction-server and exasol-testcontainers. ```shell go test ./... ``` -------------------------------- ### Import Local CSV Files Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Use the SQL driver to load data from local CSV files into Exasol. Supports multiple files and custom separators/encoding. Limitations include no FBV support and the SECURE option is not available. ```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' `) ``` -------------------------------- ### Execute Prepared SELECT Statement Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Prepares a SQL SELECT statement with a placeholder for a parameter. This is useful for executing queries with dynamic WHERE clauses. ```go preparedStatement, err := exasol.Prepare("SELECT * FROM CUSTOMERS WHERE NAME = ?") rows, err := preparedStatement.Query("Bob") ``` -------------------------------- ### Begin and Execute within a Transaction Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Initiates a new transaction and executes statements within its scope. All operations within the transaction will be atomic. ```go transaction, err := exasol.Begin() result, err := transaction.Exec( ... ) result2, err := transaction.Exec( ... ) ``` -------------------------------- ### Run Unit Tests Source: https://github.com/exasol/exasol-driver-go/blob/main/doc/developer_guide.md Execute only the unit tests for the project. This is useful for quick checks during development. ```shell go test ./... -short ``` -------------------------------- ### Enable Testcontainers Reuse Source: https://github.com/exasol/exasol-driver-go/blob/main/doc/developer_guide.md Configure testcontainers to reuse containers for faster development cycles. Create this file in your home directory. ```properties testcontainers.reuse.enable=true ``` -------------------------------- ### Create Exasol Connection with DSN String Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Connect to an Exasol database using a Data Source Name (DSN) string. Ensure that any semicolon characters within values are escaped with a backslash (`\;`). ```go package main import ( "database/sql" _ "github.com/exasol/exasol-driver-go" ) func main() { database, err := sql.Open("exasol", "exa::;user=;password=") // ... } ``` -------------------------------- ### Execute a SELECT Query Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Executes a SQL query that returns rows. The result is a `*sql.Rows` object that can be iterated over to fetch the data. ```go rows, err := exasol.Query("SELECT * FROM CUSTOMERS") ``` -------------------------------- ### Escape Semicolon in Connection String with Builder Source: https://github.com/exasol/exasol-driver-go/blob/main/doc/changes/changes_1.0.5.md Use the configuration builder to automatically escape semicolons in client names when constructing a connection string. ```go connectionString := exasol.NewConfig("", ""). Host(""). Port(8563). ClientName("My Client; Version abc"). String() ``` -------------------------------- ### Configure Connection for Manual Transaction Control Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Disables autocommit for the database connection, allowing for manual control over transaction boundaries using `Begin()`, `Commit()`, and `Rollback()`. ```go database, err := sql.Open("exasol", "exa::;user=;password=;autocommit=0") ``` ```go database, err := sql.Open("exasol", exasol.NewConfig("", "") .Port() .Host("") .Autocommit(false) .String()) ``` -------------------------------- ### SQL INSERT statement with IMPORT LOCAL CSV FILE in string Source: https://github.com/exasol/exasol-driver-go/blob/main/doc/changes/changes_1.0.4.md This SQL statement demonstrates the issue where the Go driver incorrectly detected 'IMPORT LOCAL CSV FILE' within a string literal, causing parsing errors. This was fixed in version 1.0.4. ```sql insert into table1 values ('import into {{dest.schema}}.{{dest.table}} ) from local csv file ''{{file.path}}'' '); ``` -------------------------------- ### Manually Escape Semicolon in Connection String Source: https://github.com/exasol/exasol-driver-go/blob/main/doc/changes/changes_1.0.5.md When providing a connection string directly, manually escape semicolons in client names using a backslash. ```go connectionString := `exa:localhost:1234;user=sys;password=exasol;clientname=My Client\; Version abc` ``` -------------------------------- ### Execute an INSERT Statement Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Executes a non-query SQL statement, such as an INSERT, UPDATE, or DELETE. This function is typically used for statements that do not return rows. ```go result, err := exasol.Exec ( "INSERT INTO CUSTOMERS (NAME, CITY) VALUES('Bob', 'Berlin');" ) ``` -------------------------------- ### Fix: Scan large integer values in Go Source: https://github.com/exasol/exasol-driver-go/blob/main/doc/changes/changes_1.0.9.md This snippet demonstrates the fix for scanning large integer values using rows.Scan() in the Exasol Go driver. It resolves an issue where large integers were incorrectly converted from float64, causing a 'invalid syntax' error. ```go rows.Scan(&result) ``` -------------------------------- ### Fix: Return correct error from rows.Err() in Go Source: https://github.com/exasol/exasol-driver-go/blob/main/doc/changes/changes_1.0.9.md This release ensures that rows.Err() now returns the correct error, rather than always returning driver.ErrBadConn as it did previously. This improves error diagnosis for database connection issues. ```go rows.Err() ``` -------------------------------- ### Commit a Transaction Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Commits all changes made within the current transaction to the database, making them permanent. ```go err = transaction.Commit() ``` -------------------------------- ### Deactivate Trace Logger Source: https://github.com/exasol/exasol-driver-go/blob/main/README.md Disable trace logging by setting the trace logger to nil. This is useful when debugging is no longer needed. ```go logger.SetTraceLogger(nil) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.