Created
March 8, 2023 14:36
-
-
Save developer-sdk/777481ca07baec56b92d6d0f3f0f4f00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # dsn 설정 예제 | |
| [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN] | |
| # 예제 | |
| username:password@tcp(10.0.0.1:3306)/dbname | |
| # tls | |
| username:password@tcp(10.0.0.1:3306)/dbname?tls=skip-verify |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func Connect() { | |
| db, err := sqlx.Connect("mysql", "username:password@tcp(10.0.0.1:3306)/default_db") | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| return db | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment