plain

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: MIT Imports: 11 Imported by: 0

README

lesiw.io/plain

Go Reference

A micro-framework for building applications with plain, simple, SQL.

Currently, only pgx/v5 (PostgreSQL) is supported.

Structure

Statements go in sql/statements. One statement per file. Only files ending in .sql will be used.

Migrations go in sql/migrations. Refer to the golang-migrate documentation.

Configuration

Use the libpq environment variables to configure your database connection. These are automatically understood by pgx.

Usage

Add this to the top of your application's main.go:

//go:generate go run lesiw.io/plain/cmd/plaingen@latest

Run go generate.

Use plain.ConnectPgx(context.Context) *pgxPool.pool to establish a connection to the database.

Import internal/stmt as access the SQL statements written in sql/statements.

Example

See lesiw.io/smol.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MigrationFS fs.FS

Functions

func ConnectPgx

func ConnectPgx(ctx context.Context) (pool *pgxpool.Pool)

ConnectPgx connects to the database.

Database connection information should be specified by setting standard PostgreSQL environment variables, e.g. PGHOST, PGUSER, PGPASSWORD, PGDATABASE.

Blocks until a connection has been achieved to prevent application thrashing.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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