24 lines
625 B
Go
24 lines
625 B
Go
package neo4jAPI
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
|
"github.com/neo4j/neo4j-go-driver/v5/neo4j/config"
|
|
)
|
|
|
|
func NewConnection(uri string, username string, password string) (neo4j.DriverWithContext, error) {
|
|
driver, err := neo4j.NewDriverWithContext(uri, neo4j.BasicAuth(username, password, ""),
|
|
useConsoleLogger(neo4j.INFO))
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to create Neo4j driver: %v", err)
|
|
}
|
|
return driver, nil
|
|
|
|
}
|
|
|
|
func useConsoleLogger(level neo4j.LogLevel) func(config *config.Config) {
|
|
return func(config *config.Config) {
|
|
config.Log = neo4j.ConsoleLogger(level)
|
|
}
|
|
}
|