https://github.com/brunotm/norm
A no frills, no bloat, no magic Go package for working with SQL code, databases and migrations.
https://github.com/brunotm/norm
database go golang sql
Last synced: 2 months ago
JSON representation
A no frills, no bloat, no magic Go package for working with SQL code, databases and migrations.
- Host: GitHub
- URL: https://github.com/brunotm/norm
- Owner: brunotm
- License: apache-2.0
- Created: 2021-08-13T08:46:30.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-20T10:07:41.000Z (almost 3 years ago)
- Last Synced: 2024-06-21T09:51:34.367Z (about 2 years ago)
- Topics: database, go, golang, sql
- Language: Go
- Homepage:
- Size: 77.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# norm (NoORM)
[](https://github.com/brunotm/norm/actions)
[](https://goreportcard.com/report/brunotm/norm)
[](https://pkg.go.dev/github.com/brunotm/norm)
[](https://raw.githubusercontent.com/brunotm/norm/master/LICENSE)
This repository provides a **no frills, no bloat and no magic** collection of utilities for working with SQL code and databases
in Go. It **relies solely on standard library packages** and focuses on simplicity, stability and performance.
# Packages
## [norm/statement](statement/README.md)
A simple and performant SQL query builder for Go which doesn't hide or obscures SQL code and
logic but rather makes them explicit and a fundamental part of the application code.
It handles the all parameter interpolation at the package level using the `?` placeholder, so
queries are mostly portable across databases.
### Features
* Select
* Comment
* Columns
* From (table or statement.SelectStatement)
* Join
* Where
* WhereIn
* With (statement.SelectStatement)
* WithRecursive (statement.SelectStatement)
* Having
* GroupBy
* Order
* Limit
* Offset
* Distinct
* ForUpdate
* SkipLocked
* Union (statement.SelectStatement)
* UnionAll (statement.SelectStatement)
* Insert
* Comment
* Into
* With (statement.SelectStatement)
* Returning
* Record (from struct)
* ValuesSelect (statement.SelectStatement)
* OnConflict
* Update
* Comment
* Table
* Set
* SetMap
* With (statement.SelectStatement)
* Where
* WhereIn
* Returning
* Delete
* Comment
* From
* With (statement.SelectStatement)
* Where
* WhereIn
* Returning
* DDL
* Comment
* Create
* Alter
* Truncate
* Drop
## [norm/database](database/README.md)
A safe sql.DB wrapper which enforces transactional access to the database, transaction query caching and operation logging and plays nicely with `norm/statement`.
### Features
* Contextual operation logging
* Transactional access with default isolation level
* Cursor for traversing large result sets
* Row scanning into structs or []struct
* Transaction scoped query caching
* Transaction ids for request tracing
## [norm/migrate](migrate/README.md)
A simple database migration package which does the necessary, not less, not more.
### Features
* Migration sequence management
* Migrate Up/Down/Apply()
* Apply/discard migrations
* Transactional apply/discard migrations
## Motivation
I like simple, efficient and clean code. There is too much ORM stuff floating around these days.
### Install
```shell
go get -u -v github.com/brunotm/norm
```
## Test
```shell
go test -v -cover ./...
```