Connecting to an in-memory DB

Report a typo

When working with SQLite databases, it is possible to create and connect to an in-memory database named :memory:.

Suppose you wanted to connect to the in-memory SQLite database :memory: using the functions from the GORM package. Your task is to write the required additional code to connect to :memory: using the gorm.Open() function.

Write a program in Go
package main

import (
"fmt"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"log"
)


func main() {
// Write the required code to connect to the ":memory:" database below:
db, err := ?.?(?.?(":memory:"), &gorm.Config{})
if err != nil {
log.Fatal(err)
}

// DO NOT delete the line below, it checks if a proper connection was made to ":memory:"
fmt.Println(checkConnection(db))
}
___

Create a free account to access the full topic