func GetDB() (*sql.DB, error) {
	if currentConn == nil {
		fmt.Println("Connection opened!")
		// Start the connection
		var err error
		currentConn, err = sql.Open("sqlite3", files.GetSettingsPath()+FileName)

		if err != nil {
			log.Fatalln("Unable to use the DB! " + err.Error())
		}

		// Test query to check if the DB has the expected tables
		_, err = currentConn.Exec("SELECT id FROM moodles")
		if err != nil {
			// Populate the DB
			err = populateDB()
			fmt.Println(err)
		}
		return currentConn, err
	}
	return currentConn, nil
}
// GetDB returns or creates a connection with the application's SQLite database.
// If the database doesn't exist, a new one will be created
GetDB returns or creates a connection with the application's SQLite database.
If the database doesn't exist, a new one will be created
// GetDB returns or creates a connection with the application ' s SQLite database . // If the database doesn ' t exist a new one will be created
func GetDB() (*sql.DB, error) {
	if currentConn == nil {
		fmt.Println("Connection opened!")
		var err error
		currentConn, err = sql.Open("sqlite3", files.GetSettingsPath()+FileName)
		if err != nil {
			log.Fatalln("Unable to use the DB! " + err.Error())
		}
		_, err = currentConn.Exec("SELECT id FROM moodles")
		if err != nil {
			err = populateDB()
			fmt.Println(err)
		}
		return currentConn, err
	}
	return currentConn, nil
}
func GetDB ( ) ( * sql . DB , error ) { if currentConn == nil { fmt . Println ( " " ) var err error currentConn , err = sql . Open ( " " , files . GetSettingsPath ( ) + FileName ) if err != nil { log . Fatalln ( " " + err . Error ( ) ) } _ , err = currentConn . Exec ( " " ) if err != nil { err = populateDB ( ) fmt . Println ( err ) } return currentConn , err } return currentConn , nil }
GetDB returns or creates a connection with the application's SQLite database.
GetDB returns or creates a connection with the application ' s SQLite database .
// Start the connection // Test query to check if the DB has the expected tables // Populate the DB