#Golang-Database
5 articles
How To Integrate Golang with MySQL Database
Introduction to Package Database
In Golang programming, by default it has a package called database. This package has a set of standard interfaces
which provide standards for communication into the database so that we can immediately create the program that we will create using this package to access any type of database with the same code. But what will differ is that only the SQL
query code is used according to the database used.
How to Communication Golang with MSSQL Server
Dependency
Make sure you have created a project with go mod init mssql-go
in the mssql-go
folder and the dependency that we will use is using
How To Communication Golang with MongoDB
Dependecy Needed
Add some dependency when we used
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
Create a Database Connection
create database connection function into mongoDB.
How To Communication Golang with Postgres Database
Dependency
Make sure you have created a project with go mod init postgres-go
in the postgres-go
folder and the dependency that we will use is using
How to Communication Golang with MySQL Database
Package atau Library
import "github.com/go-sql-driver/mysql"
Project Initialization
Prepare a new folder with the name mysql-native
, then initialize the Golang module to make it more modular. Here’s a quick command.