Skip to content

samtech09/dbtools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dbtools

Database modules to connect PostgreSQL, SQL-Server or MongoDB.

Each tools is self-contained module.

Features

  • Easy to use plug and play type modules.
  • Provide query splitting (read/write) for Postgres and SQL-Server.

Usage

Import, provide config and start using.

import "github.com/samtech09/dbtools/mssql"
...

func InitConnection() {
	cfg := DbConfig{"127.0.0.1", 0, "testdb", "testuser", "testuser", 30}
	db = InitDbPool(cfg, cfg)
	fmt.Println("Connection suceeded")
}

func TestOps(t *testing.T) {
	sql = "select * from table1 where age>@p1"
	rows, err := db.Conn(true).Query(sql, 10)
	if err != nil {
		t.Errorf("Select error: %s", err.Error())
		t.FailNow()
	}
	...
  // scan rows...
  ...
}

Technologies used

About

Database tools to connect PostgreSQL, SQL-Server or MongoDB

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages