Help us shape the future of Go! Take the 2026 Go Developer Survey

dbmod

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package dbmod is the native module "db": SQL databases through Go's database/sql: SQLite (modernc.org/sqlite), PostgreSQL (jackc/pgx) and MySQL or MariaDB (go-sql-driver/mysql), all pure Go, so no C library is needed.

use db;
local conn = db::open("sqlite:shop.db");
conn->exec("CREATE TABLE IF NOT EXISTS items (name TEXT, price REAL)");
conn->exec("INSERT INTO items VALUES (?, ?)", "pen", 1.5);
for (local row in conn->query("SELECT * FROM items WHERE price < ?", 10))
    println(row["name"], row["price"]);
conn->close();

Values always travel as parameters (?), never glued into the SQL text.

Index

Constants

View Source
const DBError = "DBError"

DBError is the kind of the exceptions the database reports: an SQL error, a broken constraint, a database file that cannot be opened.

Variables

View Source
var (
	Conn   = &native.Class{Name: "Conn"}
	Cursor = &native.Class{Name: "Cursor"}
)

Conn and Cursor are the classes db::Conn and db::Cursor.

View Source
var Query = &native.Class{Name: "Query"}

Query is the class db::Query: conn->find(C) and its refinements.

View Source
var Relation = &native.Class{Name: "Relation", Show: func(o *value.ObjectObj) string {
	r := o.State.(*relation)
	kind := "one"
	if r.many {
		kind = "many"
	}
	return "db::" + kind + "(" + r.class.Name + ", \"" + r.key + "\")"
}}

Relation is the class of what db::many and db::one give.

Functions

func Has added in v0.10.1

func Has(kind string) bool

Has reports whether this kukel can open databases of kind ("SQLite", "PostgreSQL" or "MySQL").

func Kinds added in v0.10.1

func Kinds() []string

Kinds names the databases this kukel can open, in order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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