sql

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package sql is the network relational database plugin covering MySQL, MariaDB and PostgreSQL. Scripts import it as scriptling.sql:

import scriptling.sql as sql
conn = sql.connect("postgres://user:pass@host:5432/app")
conn.execute("create table t (id serial primary key, name text)")
conn.execute("insert into t (name) values (?)", "ada")
rows = conn.query("select * from t where name = ?", "ada")
conn.close()

The DSN scheme picks the driver: postgres:// or postgresql:// for PostgreSQL, mysql:// or mariadb:// for MySQL and MariaDB (both speak the MySQL protocol). The query/execute/close surface is identical to the sqlite plugin; ? placeholders are translated to $n on PostgreSQL, which also accepts explicit $n. The server address must pass the host's network policy. The same library serves external plugin mode (plugins/sql/cmd) and compiled-in registration (build tag plugin_sql).

Index

Constants

View Source
const ConnectSource = `def connect(dsn):
    return Connection(dsn)
`

ConnectSource is the scriptling-source wrapper for connect() in external plugin mode, where a Go function cannot return an instance over the wire: it constructs the Connection class through the plugin object protocol.

View Source
const Description = "MySQL, MariaDB and PostgreSQL client"

Description is the plugin metadata description.

Variables

This section is empty.

Functions

func Build

func Build(policy plugin.PolicySource) *object.Library

Build returns the scriptling.sql library. policy is read at call time so an external plugin sees the policy its handshake delivered.

func RegisterInProcess

func RegisterInProcess(registrar interface {
	RegisterLibrary(*object.Library)
	RegisterScriptLibrary(name string, script string) error
}, policy *plugin.Policy)

RegisterInProcess registers both halves for embedders and tests.

func ScriptModule

func ScriptModule() string

ScriptModule is the user-facing scriptling.sql module for compiled-in registration: the Connection wrapper (with get_orm) plus the shared ORM kit, importing the native twin.

Types

This section is empty.

Directories

Path Synopsis
Command sql serves the MySQL/MariaDB/PostgreSQL plugin over the Scriptling plugin protocol (stdio JSON-RPC).
Command sql serves the MySQL/MariaDB/PostgreSQL plugin over the Scriptling plugin protocol (stdio JSON-RPC).

Jump to

Keyboard shortcuts

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