godb

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: MIT Imports: 7 Imported by: 0

README

godb

USE

package database

import (
	"gorm.io/gorm"
	"ruan.co/godb"
)

func init()  {
	dialects := "mysql"
	dsn := "root:123456@tcp(127.0.0.1:3306)/godb?charset=utf8mb4&parseTime=True&loc=Local"
	
	// dialects := "sqlite"
	// dsn := "godb.db"
	
	// dialects := "postgres"
	// dsn := "host=localhost user=root password=123456 dbname=gorm port=9920 sslmode=disable TimeZone=Asia/Shanghai"

	// dialects := "sqlserver"
	// dsn := "sqlserver://root:123456@localhost:9930?database=godb"

	// dialects := "clickhouse"
	// dsn := "tcp://localhost:9000?database=godb&username=root&password=123456&read_timeout=10&write_timeout=20"
	
	db, err := godb.NewConnection(dialects, dsn, &gorm.Config{PrepareStmt: true}).InitDB()
    
	// TODO DIY USE
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Dialects string
	Dsn      string
	Config   *gorm.Config
}

func NewConnection

func NewConnection(dialects string, dsn string, config *gorm.Config) *Connection

func (*Connection) InitDB

func (c *Connection) InitDB() (*gorm.DB, error)

Jump to

Keyboard shortcuts

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