In this project is about to learn how to do database CRUD operations using Golang and MySQL. CRUD is an acronym for Create, Read, Update, and Delete. CRUD operations are basic data manipulation for database.
Using Git Bash first install driver for Go's MySQL database package. Run below command and install MySQL driver's
go get -u github.com/go-sql-driver/mysql
Now create Goblog Database
- Open PHPMyAdmin/SQLyog or what ever MySQL database management tool that you are using.
- Create a new database "go_employee"
DROP TABLE IF EXISTS `employee`;
CREATE TABLE `employee` (
`id` int(6) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
`city` varchar(30) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
Change directory to this project and run command below to start project.
go run employee.go