Questions about golang and database connections, clients and drivers?

for example, go connection mysql, https://github.com/jmoiron/sqlx is a client that implements official database/sql, and an additional driver: https://github.com/go-sql-dri. is required to use it.

but this is not the case when I connect to mongodb. I can interact with mongo server directly using https://github.com/go-mgo/mgo. is it because mgo integrates both the driver and the client?

now it is found that mongo is officially open source: https://github.com/mongodb/mo.. It seems that it can be used directly, and there will be no separation of the driver from the client

.

mongodb is a non-relational database product produced by a company, and mgo itself plays the role of the driver. Sqlx is equivalent to the database abstraction layer that accords with SQL access mode, and its function is similar to the jdbc standard in java. Specifically, each database product needs to be adapted according to each product, that is, it needs to be driven.


golang's database/sql package name shows that it is related to a relational database. Only one set of abstract interfaces is provided. Go-sql-driver implements the driver of this interface. When we use it, we can just use database/sql directly. this is called interface-oriented programming

.

mgo is the connector of Mongodb and has nothing to do with the database/sql interface.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b33419-2be84.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b33419-2be84.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?