39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package otter
|
|
|
|
import (
|
|
"context"
|
|
"git.dragse.it/anthrove/otter-space-sdk/pkg/database"
|
|
)
|
|
|
|
func ConnectToGraphDatabase(ctx context.Context, endpoint string, username string, password string, debug bool) (database.OtterSpace, error) {
|
|
var graphConnection database.OtterSpace
|
|
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)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return graphConnection, err
|
|
}
|