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.
e621-sdk-go/neo4jAPI/connection.go

23 lines
572 B
Go
Raw Normal View History

2023-05-22 14:00:01 +00:00
package neo4jAPI
import (
"fmt"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
)
func NewConnection(uri string, username string, password string) (neo4j.DriverWithContext, error) {
2023-05-26 10:19:36 +00:00
driver, err := neo4j.NewDriverWithContext(uri, neo4j.BasicAuth(username, password, ""),
useConsoleLogger(neo4j.DEBUG))
2023-05-22 14:00:01 +00:00
if err != nil {
return nil, fmt.Errorf("failed to create Neo4j driver: %v", err)
}
return driver, nil
}
2023-05-26 10:19:36 +00:00
func useConsoleLogger(level neo4j.LogLevel) func(config *neo4j.Config) {
return func(config *neo4j.Config) {
config.Log = neo4j.ConsoleLogger(level)
}
}