Skip to content

Instantly share code, notes, and snippets.

@Apurer
Created April 8, 2024 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Apurer/bb8e6a6c9bc285934d5a39b6516aba21 to your computer and use it in GitHub Desktop.
Save Apurer/bb8e6a6c9bc285934d5a39b6516aba21 to your computer and use it in GitHub Desktop.
import (
"database/sql"
_ "github.com/microsoft/go-mssqldb"
_ "github.com/microsoft/go-mssqldb/integratedauth/krb5"
)
func main() {
// Replace with actual values
connectionString := "authenticator=krb5;server=your_server_name;database=your_database_name;user id=your_username;krb5-realm=comani.com;krb5-configfile=/etc/krb5.conf;"
// Open connection using the connection string
conn, err := sql.Open("mssql", connectionString)
if err != nil {
panic(err)
}
defer conn.Close()
// Execute SQL statements using the connection (replace with your queries)
rows, err := conn.Query("SELECT * FROM your_table")
if err != nil {
panic(err)
}
defer rows.Close()
// Process rows (implement your logic here)
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment