Sql.Open() Parameters


I do not understand the parameters in the sql.Open() function. Particularly the second one that looks like this… user:password(ip)/table

Please help with an explanation on how to relate this to my own localhost. The documentation is not clear on the parameters.


That’s a Data source name. You can read a bit more about it on wikipedia:

Which database driver are you using?

1 Like

Yeah, thanks. j1436go

The syntax is a major issue.

// Could also be "user:@/dbname" if no password and on localhost.
db, err := sql.Open("mysql", "user:password@localhost/dbname")
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.