-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
35 lines (29 loc) · 991 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package oracle
import (
"encoding/json"
"github.com/as-tool/as-etl-engine/common/config"
"github.com/godror/godror"
)
type Config struct {
URL string `json:"url"` // Database URL, including the database address and other database parameters
Username string `json:"username"` // Username
Password string `json:"password"` // Password
}
// NewConfig creates an Oracle configuration and will report an error if the format does not meet the requirements
func NewConfig(conf *config.JSON) (c *Config, err error) {
c = &Config{}
err = json.Unmarshal([]byte(conf.String()), c)
if err != nil {
return nil, err
}
return
}
// FetchConnectionParams retrieves the Oracle connection parameters and will report an error if the URL is incorrect
func (c *Config) FetchConnectionParams() (con godror.ConnectionParams, err error) {
if con, err = godror.ParseDSN(c.URL); err != nil {
return
}
con.Username = c.Username
con.Password = godror.NewPassword(c.Password)
return
}