gosql

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2020 License: MIT Imports: 2 Imported by: 0

README

go-sql

Go Report Card license

This project is a db connector for SQL databases. And so support to trace context like opentracing.

In this time, mysql is to support only. Continuously expect to support databases like Sqlite, BigQuery, and so on.

Getting Started

Mysql
package main

import (
	gomysql "github.com/gjbae1212/go-sql/mysql"
)

func main() {
    // conn, err := gomysql.NewConnectorWithOpentracing("user:password@/dbname", 2)
	conn, err := gomysql.NewConnector("user:password@/dbname", 2)
	if err != nil {
		panic(err)
	}

	if err := conn.Connect(); err != nil {
		panic(err)
	}

	// db is *gorm.DB(https://github.com/jinzhu/gorm)
	db, err := conn.DB()
	if err != nil {
		panic(err)
	}	
}

To be Supported

  • Sqlite
  • Postgres
  • BigQuery
  • And so on ...

License

This project is licensed under the MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidParam  = fmt.Errorf("[err][gosql] invalid param")
	ErrNotExistDB    = fmt.Errorf("[err][gosql] not exist db")
	ErrFailConnectDB = fmt.Errorf("[err][gosql] fail connect db")
)

Functions

This section is empty.

Types

type Connector

type Connector interface {
	DSN() string
	DriverName() string
	DB() (*sql.DB, error)
	Connect() error
	Close()
}

Connector is common interface for SQL like database. This interface is to support methods like connect, close and so on.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL