Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YohGo database

YohGo database manages the database connection of an application so that the database connection is wrapped in a configurable container that can be utilised in various packages that require a connection to a database.



Requirements

  • Go (1.5+)
  • MySQL (4.1+)

Features

  • Lightweight and fast
  • Native Go implementation
  • Currently only supports mysql and gorm mysql

Installation

Simply install the package to your $GOPATH with the go tool from shell:

$ go get github.com/yohgo/database

Make sure Git is installed on your machine and in your system's PATH.


Usage

YohGo Database is a Go database container that. You only need to import the YohGo database package of choice and can use the full database/sql API then.

Example of using the gorm package:

import (
    "github.com/yohgo/database/gorm"
)

// Configure database connection
database, err := gorm.NewDatabase("DB_USER", "DB_PASS", "DB_HOST", "DB_PORT", "DB_NAME")
// Check if connection failed
if err != nil {
    log.Fatal("Failed to connect to database")
}
// Always ensure to close the connection
defer database.Close()

Example of using the mysql package:

import (
    "github.com/yohgo/database/mysql"
)

// Configure database connection
database, err := mysql.NewDatabase("DB_USER", "DB_PASS", "DB_HOST", "DB_PORT", "DB_NAME")
// Check if connection failed
if err != nil {
    log.Fatal("Failed to connect to database")
}
// Always ensure to close the connection
defer database.Close()

About

yohgo/pastry is a package that manages a database connection

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages