Files
knowledge-graph-agent/backend/neo4j/client.go
T
2026-04-13 14:36:54 +08:00

28 lines
474 B
Go

package neo4j
import (
"context"
"fmt"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
"knowledge-graph-backend/config"
)
func DoConnect(cfg config.Neo4jConfig) {
ctx := context.Background()
driver, err := neo4j.NewDriverWithContext(
cfg.URI,
neo4j.BasicAuth(cfg.Username, cfg.Password, ""))
if err != nil {
panic(err)
}
defer driver.Close(ctx)
err = driver.VerifyConnectivity(ctx)
if err != nil {
panic(err)
}
fmt.Println("Connection established.")
}