MongoDB – Can not connect the database by Mongodb ODBC Driver Windows

Hello Friends,

So many users are complaining that they cannot connect to the Mongodb with the ODBC Driver so today I am gonna write this tutorial as I was also stuck with the MongoDB ODBC connector issue on windows and did not find any help over the internet. So after debugging lots of hours i finally able to connect with the MongoDB ODBC with my server. So, first of all, you need to download these prerequisites.

Step 1: Prerequisites

Step 2: Connecting to Database via mongosqld

mongosqld --mongo-uri "mongodb://13.251.86.51:27017" --auth --mongo-username lucifer --mongo-password Pass1234 --mongo-authenticationSource admin
  • Open Command Prompt and run the above query until it fully samples the whole schema and shows you all the collections names in the cli like this

Step 3: Connecting via ODBC

Now Test the connection. That’s all. 🙂

Golang — Extract value from interfaces{} without specifying the Struct Type

Let say you pass struct as an interface argument to function and you do not have access to the type struct then how to extract the fields values.

Now you are trying to figure out why the heck i need to do this, lol. But there are many cases where you do not have access to the TYPE.

Let’s take an example i am building a go pkg and i want user to specify there own Table Struct but on my pkg i want to access the values of that struct which i do not have access to directly.

Live Example: https://play.golang.org/p/73OH5zYxjAF

package main
import (
 "fmt"
 "reflect"
)
type User struct {
 UserEmail string
 UserPass  string
}
func login(user interface{}) {
 
 ////--- Extract Value without specifying Type
 val := reflect.ValueOf(user).Elem()
 n := val.FieldByName("UserEmail").Interface().(string)
 fmt.Printf("%+v\n", n)
 
 fmt.Println(user.(*User).UserEmail)
}
func main() {
 login(&User{UserEmail: "[email protected]", UserPass: "lucian123"})
}

×