Skip to content

Database Helper methods for Go Lang. Copies Results to Memory and keeps the Server Query time to a minimum. Best used for Result sets that require heavy loop processing.

License

Notifications You must be signed in to change notification settings

GuneshRaj/Go-DBBasic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Go-DBBasic

Database Helper methods for GoLang Based on DBBasic in Java, PHP

Methods for Simplifying development in Go Lang.

Update Statement

sql : Standard SQL statement thats meant to be Executed by the server - eg Insert, Update or Delete

func updateStatement(db *sql.DB, sql string) error
err = updateStatement(db, "insert into pix(id, title) values(103, 'One Hundred One')")

Select Statement

sql : Standard SQL statement thats meant to be Queried by the server - Usually Select

Returns an Array of Map of the result set. []map[string]string

func selectStatement(db *sql.DB, sql string) ([]map[string]string, error)
	clist := []map[string]string{}
	clist, _ = selectStatement(db, "SELECT customername FROM customers limit 2")
	for i, x := range clist {
		fmt.Println(i, x["customername"])
	}

Select Single Statement

sql : Standard SQL statement for 1 record thats meant to be Queried by the server - Usually Select

Returns a Map of the result set. map[string]string

func selectSingleStatement(db *sql.DB, sql string) (map[string]string, error)
	cdata := map[string]string{}
	cdata, _ = selectSingleStatement(db, "SELECT customername FROM customers limit 1")
	fmt.Println(cdata["customername"])

Select Data

sql : Standard SQL statement for 1 record and 1 data thats meant to be Queried by the server - Usually Select x from A limit 1

Returns a string of the data returned

func selectData(db *sql.DB, sql string) (string, error)
	data := ""
	data, _ = selectData(db, "SELECT customername FROM customers limit 1")
	fmt.Println(data)

Note

Data are returned as string at the moment.

Aims to keep the Query session open to a minimum, so the results are coppied to the App memory.

The SQL statement needs to be safe, the code does not do that.

About

Database Helper methods for Go Lang. Copies Results to Memory and keeps the Server Query time to a minimum. Best used for Result sets that require heavy loop processing.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages