dbutil

package
v0.0.0-...-a101d14 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

dbutil

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rows2Map

func Rows2Map(rows *sql.Rows) ([]map[string]interface{}, error)

Rows2Map convers rows to []map[string]interface{} caller call the function rows.Close()

func Sql2Map

func Sql2Map(db *sql.DB, strSql string, args ...interface{}) ([]map[string]interface{}, error)

Sql2Map convers query to []map[string]interface{}

That's a specialty of MySQL: you have to use prepared statements to get the native types. MySQL has two protocols, one transmits everything as text, the other as the "real" type. And that binary protocol is only used when you use prepared statements. The driver is pretty much powerless to enforce a protocol and the text protocol takes less resources on the server.

This may help you:

stmt, err := db.Prepare(sqlString) if err != nil { ...... } defer stmt.Close() rows, err := stmt.Query()

Types

This section is empty.

Jump to

Keyboard shortcuts

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