database

package
v0.0.0-...-2eef10d Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

README

This is a repo just for database connect and operate.

Use this repo, you can connect database easily. Maybe it's useful for beginner.

Docker-compose

Docker-compose.yml file can start mongodb and mysql container, and you can connect them and do some useful things.

ok, let's begin!

MySQl Operate

The operate about mysql are show in the file mysql.go and mysql_test.go is the test file. In this code, I create three table which come from the openstack swift.

  • Run Docker Container in this folder, i use docker-compose run mysql and mongodb container, you can run those just run
docker-compose up -d

and then, you can run the test, just run

go test

This is just for someone beginner or those people who is beginner for go, or intersted in golang. Ok, Let's make go better together!

Documentation

Index

Constants

View Source
const (
	// ContainTable is the swift table create sql
	ContainTable = `` /* 281-byte string literal not displayed */

	// AccountTable is the swift table create sql
	AccountTable = `` /* 396-byte string literal not displayed */

	// PolicyTable is the swift table create sql
	PolicyTable = `` /* 176-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func CloseConn

func CloseConn(db *sql.DB)

CloseConn 关闭MySQL连接

func KillQuerySession

func KillQuerySession(db *sql.DB, sessionId int64) error

KillQuerySession 杀死查询Session

func KillSession

func KillSession(db *sql.DB, sessionId int64) error

KillSession �杀死Session

func NewConn

func NewConn(conn MySQLConn) (*sql.DB, error)

NewConn 创建一个MySql连接。

Types

type MySQLConn

type MySQLConn struct {
	Host     string
	Port     int
	User     string
	Dbname   string
	Password string
	ChartSet string
}

MySQLConn is the config struct

Jump to

Keyboard shortcuts

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