28 lines
474 B
Go
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.")
|
|
}
|