mirror of
https://github.com/vcscsvcscs/GenerationsHeritage.git
synced 2025-08-14 14:59:07 +02:00
create memgraph db connection
This commit is contained in:
22
backend/memgraph/init_database.go
Normal file
22
backend/memgraph/init_database.go
Normal 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)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user