create memgraph db connection

This commit is contained in:
2024-04-14 11:15:01 +02:00
parent a6718b2487
commit 35f478e24c
4 changed files with 28 additions and 48 deletions

View File

@@ -0,0 +1,22 @@
package memgraph
import (
"context"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
)
func InitDatabase(dbUri, dbUser, dbPassword string) error {
driver, err := neo4j.NewDriverWithContext(dbUri, neo4j.BasicAuth(dbUser, dbPassword, ""))
if err != nil {
return err
}
ctx := context.Background()
defer driver.Close(ctx)
err = driver.VerifyConnectivity(ctx)
if err != nil {
panic(err)
}
}