Open arvenil opened 4 years ago
pq also seem to understand database URLs. Therefore building one with the url package should escape everything properly.
dbURI, err := url.Parse("postgres://localhost:5432/postgres?sslmode=disable")
_ = err
dbURI.User = url.UserPassword("postgres", "postgres")
db, err := sql.Open("postgres", dbURI.String())
_ = err
What's the proper way to escape password and other parameters in connection string? Is there a function that can be used for that?