Add postgres support #135
|
@ -140,7 +140,7 @@ func initPostgresEngine() (engine *xorm.Engine, err error) {
|
|||
var connStr string
|
||||
host, port := parsePostgreSQLHostPort(config.DatabaseHost.GetString())
|
||||
if strings.HasPrefix(config.DatabaseHost.GetString(), "/") { // looks like a unix socket
|
||||
connStr = fmt.Sprintf("postgres://%s:%s@:%s/%ssslmode=%s&host=%s",
|
||||
connStr = fmt.Sprintf("postgres://%s:%s@:%s/%s?sslmode=%s&host=%s",
|
||||
|
||||
url.PathEscape(config.DatabaseUser.GetString()),
|
||||
url.PathEscape(config.DatabasePassword.GetString()),
|
||||
port,
|
||||
|
@ -148,7 +148,7 @@ func initPostgresEngine() (engine *xorm.Engine, err error) {
|
|||
config.DatabaseSslMode.GetString(),
|
||||
jtojnar
commented
I am not sure if these flags are needed. I am not sure if these flags are needed.
jtojnar
commented
I am not sure if these flags are needed. I am not sure if these flags are needed.
konrad
commented
I'd say yes, since the max number of open connections can be a limiting factor for performance. I'd say yes, since the max number of open connections can be a limiting factor for performance.
|
||||
host)
|
||||
} else {
|
||||
connStr = fmt.Sprintf("postgres://%s:%s@%s:%s/%ssslmode=%s",
|
||||
connStr = fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=%s",
|
||||
url.PathEscape(config.DatabaseUser.GetString()),
|
||||
url.PathEscape(config.DatabasePassword.GetString()),
|
||||
host,
|
||||
|
|
Loading…
Reference in New Issue
Why not just use the
attr=name
format instead of URI format? Or use this one for both UNIX socket and TCP connection? This only needs to be used for UNIX sockets because URI hostnames cannot contain/
but the other way around is fine.Good point. What do think would be better suited, using the same for both or using the
attr=name
format?I think
attr=%s
is clearer.Then lets change it.