This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
plug-sdk/pkg/otter/connect.go

39 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-02-20 18:11:34 +00:00
package otter
import (
"context"
"git.dragse.it/anthrove/otter-space-sdk/pkg/database"
2024-02-20 18:11:34 +00:00
)
func ConnectToGraphDatabase(ctx context.Context, endpoint string, username string, password string, debug bool) (database.OtterSpace, error) {
var graphConnection database.OtterSpace
2024-02-20 18:11:34 +00:00
var err error
graphConnection = database.NewGraphConnection(debug)
err = graphConnection.Connect(ctx, endpoint, username, password, "", 0, "", "")
if err != nil {
return nil, err
}
return graphConnection, err
}
func ConnectToPostgresDatabase(ctx context.Context, endpoint string, username string, password string, databaseName string, port int, ssl bool, timezone string, debug bool) (database.OtterSpace, error) {
var graphConnection database.OtterSpace
var err error
var sslString string
graphConnection = database.NewPostgresqlConnection(debug)
if ssl {
sslString = "disable"
} else {
sslString = "require"
}
err = graphConnection.Connect(ctx, endpoint, username, password, databaseName, port, sslString, timezone)
2024-02-20 18:11:34 +00:00
if err != nil {
return nil, err
}
return graphConnection, err
}