Categorygithub.com/canonical/sqlair
modulepackage
0.0.0-20241004123011-77313b5382fd
Repository: https://github.com/canonical/sqlair.git
Documentation: pkg.go.dev

# README

SQLair

Go Reference Documentation Status Go Report Card CI License

SQLair is a Go package and an extension to SQL that makes it easy to map between Go types and a SQL database.

Contents

:airplane: Fly SQLair

Reading and writing to a database in Go can be hard. The solutions out there are often either too prescriptive (e.g., Object-Relational Mapping (ORM) libraries where you lose the ability to write your own SQL) or too basic (e.g., database/sql, where you have to manually iterate over each row you get back from the database).

SQLair fills the gap in the middle – automatic type mapping plus the ability to write any SQL you wish. Write your types directly into the query with SQLair expressions and SQLair will automatically map them to the query arguments and inject them with the query results.

If you’re looking to streamline your database game, go get SQLair today.

:dart: Features

  • Maps database inputs and outputs to Go types
  • Simple API
  • Database agnostic
  • Automatic statement caching

:zap: Get Started

Get started with the SQLair tutorial.

:open_book: Documentation

See the documentation on Read the Docs and in the Go Package Reference.

:dizzy: Contributing

See our CONTRIBUTING.md.

# Functions

MustPrepare is the same as [Prepare] except that it panics on error.
NewDB creates a new [sqlair.DB] from a [sql.DB].
Prepare takes a query containing SQLair expressions along with samples of all the types referenced in these SQLair expressions.

# Variables

No description provided by the author
No description provided by the author

# Structs

No description provided by the author
Iterator is used to iterate over the results of the query.
Outcome holds metadata about executed queries, and can be provided as the first output argument to any of the Get methods to populate it with information about the query execution.
Query represents a query on a database.
Statement represents a parsed SQLair statement ready to be run on a database.
TX represents a transaction on the database.
TXOptions holds the transaction options to be used in [DB.Begin].

# Type aliases

No description provided by the author
S is a slice type that, as with other named slice types, can be used with SQLair to pass a slice of input values.