Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devlights/sqlmap
A small library that maps the results of *sql.Rows to map[string]any.
https://github.com/devlights/sqlmap
database go golang sql utility
Last synced: 7 days ago
JSON representation
A small library that maps the results of *sql.Rows to map[string]any.
- Host: GitHub
- URL: https://github.com/devlights/sqlmap
- Owner: devlights
- License: mit
- Created: 2023-12-20T07:46:03.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-05-16T10:07:46.000Z (6 months ago)
- Last Synced: 2024-10-10T19:11:06.259Z (28 days ago)
- Topics: database, go, golang, sql, utility
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sqlmap
A small library that maps the results of ```*sql.Rows``` to ```[]map[string]any```.
## Install
```sh
go get github.com/devlights/sqlmap@latest
```## Usage
```go
var (
db *sql.DB
err error
)db, _ := sql.Open("sqlite", "path/to/db")
defer db.Close()var (
rows *sql.Rows
)rows, _ := db.Query("SELECT * FROM xxxxx")
defer rows.Close()var (
mapRows []RowView
)mapRows, err := sqlmap.MapRows(rows)
if err != nil {
return err
}fmt.Println(mapRows)
for _, v := range m {
name, err := v.Get("Name")
if err != nil {
t.Error(err)
}fmt.Printf("[row] %v\n", name)
}
```