(env *Environment)
| 96 | } |
| 97 | |
| 98 | func GetConnection(env *Environment) (*sql.DB, string, error) { |
| 99 | db, err := sql.Open(env.Dialect, env.DataSource) |
| 100 | if err != nil { |
| 101 | return nil, "", fmt.Errorf("Cannot connect to database: %w", err) |
| 102 | } |
| 103 | |
| 104 | // Make sure we only accept dialects that were compiled in. |
| 105 | _, exists := dialects[env.Dialect] |
| 106 | if !exists { |
| 107 | return nil, "", fmt.Errorf("Unsupported dialect: %s", env.Dialect) |
| 108 | } |
| 109 | |
| 110 | return db, env.Dialect, nil |
| 111 | } |
| 112 | |
| 113 | // GetVersion returns the version. |
| 114 | func GetVersion() string { |
no outgoing calls
no test coverage detected
searching dependent graphs…