Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1634712 Support for toml file connection configuration #1204

Merged
merged 53 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
617a495
implemented toml connection config
sfc-gh-ext-simba-jy Aug 30, 2024
93fed7d
added testing toml file
sfc-gh-ext-simba-jy Aug 30, 2024
97d0ace
Merge branch 'SNOW-1634712' of https://github.com/snowflakedb/gosnowf…
sfc-gh-ext-simba-jy Aug 30, 2024
cc025d3
fix lint
sfc-gh-ext-simba-jy Aug 30, 2024
873f7b7
add comments
sfc-gh-ext-simba-jy Aug 31, 2024
0575096
fix lint
sfc-gh-ext-simba-jy Aug 31, 2024
be15d2e
add more testing cases
sfc-gh-ext-simba-jy Sep 5, 2024
f36fc27
fix
sfc-gh-ext-simba-jy Sep 5, 2024
1a79d15
add more testing
sfc-gh-ext-simba-jy Sep 5, 2024
a9825c5
fix lint
sfc-gh-ext-simba-jy Sep 6, 2024
7e67b83
fix error
sfc-gh-ext-simba-jy Sep 6, 2024
f68f8c9
replaced all if to assertX in the testing codes
sfc-gh-ext-simba-jy Sep 7, 2024
41b35ae
fix typos
sfc-gh-ext-simba-jy Sep 7, 2024
3d6151f
updated doc, add sample application
sfc-gh-ext-simba-jy Sep 9, 2024
a7e234f
add sample file
sfc-gh-ext-simba-jy Sep 9, 2024
234532a
added details and modified the file permission to unify
sfc-gh-ext-simba-jy Sep 9, 2024
84ba09d
remove var keywords
sfc-gh-ext-simba-jy Sep 10, 2024
9eeaaf3
fix error and refactored code
sfc-gh-ext-simba-jy Sep 10, 2024
4eaa365
add error
sfc-gh-ext-simba-jy Sep 10, 2024
54bf520
fix the file permission issue
sfc-gh-ext-simba-jy Sep 10, 2024
f7e1932
fix lint
sfc-gh-ext-simba-jy Sep 10, 2024
061445f
refactored
sfc-gh-ext-simba-jy Sep 10, 2024
54123eb
remove spaces
sfc-gh-ext-simba-jy Sep 10, 2024
9fcaaff
fix
sfc-gh-ext-simba-jy Sep 11, 2024
363fb30
fix error message
sfc-gh-ext-simba-jy Sep 12, 2024
3c880d0
lint fix
sfc-gh-ext-simba-jy Sep 12, 2024
d345463
add one more testing to read token from a file
sfc-gh-ext-simba-jy Sep 12, 2024
bc2f515
add mock token file
sfc-gh-ext-simba-jy Sep 12, 2024
2099982
add more testing cases
sfc-gh-ext-simba-jy Sep 12, 2024
3b2e086
moved the testing token file
sfc-gh-ext-simba-jy Sep 12, 2024
9dbe2ab
add copyright
sfc-gh-ext-simba-jy Sep 12, 2024
9c8c150
fix
sfc-gh-ext-simba-jy Sep 12, 2024
8a761ae
Merge branch 'master' into SNOW-1634712
sfc-gh-ext-simba-jy Sep 25, 2024
c574411
updated
sfc-gh-ext-simba-jy Sep 26, 2024
8948cd0
Merge branch 'SNOW-1634712' of https://github.com/snowflakedb/gosnowf…
sfc-gh-ext-simba-jy Sep 26, 2024
13cbdbb
fixed
sfc-gh-ext-simba-jy Sep 26, 2024
cf175f1
fix
sfc-gh-ext-simba-jy Sep 27, 2024
cdc9031
lint fix
sfc-gh-ext-simba-jy Sep 27, 2024
23a254d
fix
sfc-gh-ext-simba-jy Oct 1, 2024
8f40338
add permission testing
sfc-gh-ext-simba-jy Oct 2, 2024
608fb0c
fix testing error message
sfc-gh-ext-simba-jy Oct 2, 2024
494b5b7
Merge branch 'master' into SNOW-1634712
sfc-gh-ext-simba-jy Oct 2, 2024
418705d
removed unnecessary DSN
sfc-gh-ext-simba-jy Oct 2, 2024
6042d91
fixed testing
sfc-gh-ext-simba-jy Oct 2, 2024
a4d7d51
fix error
sfc-gh-ext-simba-jy Oct 2, 2024
107d018
fix
sfc-gh-ext-simba-jy Oct 3, 2024
4a2d819
added error code for the validation and fixed the bug for cmd tomlcon…
sfc-gh-ext-simba-jy Oct 3, 2024
cd0beeb
fix
sfc-gh-ext-simba-jy Oct 3, 2024
b50ee96
Merge branch 'master' into SNOW-1634712
sfc-gh-ext-simba-jy Oct 8, 2024
c995093
updated
sfc-gh-ext-simba-jy Oct 9, 2024
d9e26d9
Merge branch 'SNOW-1634712' of https://github.com/snowflakedb/gosnowf…
sfc-gh-ext-simba-jy Oct 9, 2024
ca427b7
Merge branch 'master' into SNOW-1634712
sfc-gh-ext-simba-jy Oct 11, 2024
e6798f0
Merge branch 'master' into SNOW-1634712
sfc-gh-ext-simba-jy Oct 16, 2024
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
1 change: 1 addition & 0 deletions cmd/tomlfileconnection/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tomlfileconnection.go
16 changes: 16 additions & 0 deletions cmd/tomlfileconnection/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include ../../gosnowflake.mak
sfc-gh-pfus marked this conversation as resolved.
Show resolved Hide resolved
CMD_TARGET=tomlfileconnection

## Install
install: cinstall

## Run
run: crun

## Lint
lint: clint

## Format source codes
fmt: cfmt

.PHONY: install run lint fmt
58 changes: 58 additions & 0 deletions cmd/tomlfileconnection/tomlfileconnection.go
sfc-gh-pmotacki marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Example: How to connect to the server with the toml file configuration
// Prerequiste: following the Snowflake doc: https://docs.snowflake.com/en/developer-guide/snowflake-cli-v2/connecting/specify-credentials
package main

import (
"database/sql"
"flag"
"fmt"
"log"
"os"

sf "github.com/snowflakedb/gosnowflake"
)

func main() {
if !flag.Parsed() {
flag.Parse()
}

os.Setenv("SNOWFLAKE_HOME", "<The directory path where the toml file exists>")
os.Setenv("SNOWFLAKE_DEFAULT_CONNECTION_NAME", "<DSN Name>")

cfg, err := sf.LoadConnectionConfig()
sfc-gh-pmotacki marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
log.Fatalf("failed to create Config, err: %v", err)
}
dsn, err := sf.DSN(cfg)
if err != nil {
log.Fatalf("failed to create DSN from Config: %v, err: %v", cfg, err)
}

db, err := sql.Open("snowflake", dsn)
if err != nil {
log.Fatalf("failed to connect. %v, err: %v", dsn, err)
}
defer db.Close()
query := "SELECT 1"
rows, err := db.Query(query) // no cancel is allowed
sfc-gh-pfus marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
log.Fatalf("failed to run a query. %v, err: %v", query, err)
}
defer rows.Close()
var v int
for rows.Next() {
sfc-gh-pfus marked this conversation as resolved.
Show resolved Hide resolved
err := rows.Scan(&v)
if err != nil {
log.Fatalf("failed to get result. err: %v", err)
}
if v != 1 {
log.Fatalf("failed to get 1. got: %v", v)
}
}
if rows.Err() != nil {
fmt.Printf("ERROR: %v\n", rows.Err())
return
}
fmt.Printf("Congrats! You have successfully run %v with Snowflake DB!\n", query)
}
Loading
Loading