generateseries

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: ISC Imports: 2 Imported by: 0

Documentation

Overview

Package generateseries provides a port of the generate_series table-valued function from the SQLite tree.

Example
package main

import (
	"fmt"
	"log"

	"zombiezen.com/go/sqlite"
	"zombiezen.com/go/sqlite/ext/generateseries"
	"zombiezen.com/go/sqlite/sqlitex"
)

func main() {
	conn, err := sqlite.OpenConn(":memory:")
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	if err := generateseries.Register(conn); err != nil {
		log.Fatal(err)
	}
	err = sqlitex.ExecuteTransient(
		conn,
		`SELECT * FROM generate_series(0, 20, 5);`,
		&sqlitex.ExecOptions{
			ResultFunc: func(stmt *sqlite.Stmt) error {
				fmt.Printf("%2d\n", stmt.ColumnInt(0))
				return nil
			},
		},
	)
	if err != nil {
		log.Fatal(err)
	}

}
Output:

 0
 5
10
15
20

Index

Examples

Constants

This section is empty.

Variables

View Source
var Module = &sqlite.Module{
	Connect: connect,
}

Module is a virtual table module that can be registered with sqlite.Conn.SetModule.

Functions

func Register

func Register(c *sqlite.Conn) error

Register registers the "generate_series" table-valued function on the given connection.

Types

This section is empty.

Jump to

Keyboard shortcuts

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