Files
knowledge-graph-agent/backend/neo4j/client.go
T

27 lines
442 B
Go
Raw Normal View History

2026-04-12 15:47:48 +08:00
package neo4j
import (
"context"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
2026-04-13 14:36:54 +08:00
"knowledge-graph-backend/config"
2026-04-12 15:47:48 +08:00
)
2026-04-13 14:45:14 +08:00
func NewDriver(cfg config.Neo4jConfig) neo4j.DriverWithContext {
2026-04-13 14:36:54 +08:00
ctx := context.Background()
driver, err := neo4j.NewDriverWithContext(
cfg.URI,
neo4j.BasicAuth(cfg.Username, cfg.Password, ""))
if err != nil {
panic(err)
}
2026-04-12 15:47:48 +08:00
2026-04-13 14:36:54 +08:00
err = driver.VerifyConnectivity(ctx)
if err != nil {
panic(err)
}
2026-04-13 14:45:14 +08:00
return driver
2026-04-12 15:47:48 +08:00
}