connect

package
v1.40.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Connect provides a standardization of connecting to a database.

The example below shows storing passwords in a database.

Example:

At first you will need to implement the concrete implementation of the [Table] interface. In a package containing the type to store (in this case passwords):

import "github.com/Polshkrev/gopolutils/table"

var _ table.Table[password.Password] = (*Table)(nil)

const (
	TableName string = "passwords"
)

var (
	fieldString = table.GetFields( // The variadic table column names )
)

type Table struct {
	// Implementation of the table...
}

// Methods for the table...

Setup for a database:

import(
	"github.com/Polshkrev/gopolutils/fayl"
	"github.com/Polshkrev/gopolutils/table"
	"github.com/Polshkrev/gopolutils/table/connect"
)

var (
	path *fayl.Path = fayl.PathFrom("path/to/database.db")
)

func main() {
	var connection *sql.DB = gopolutils.Must(connect.Connect(driver, path))
	var database table.Table[password.Password] = password.NewTable(connection)
	database.Create(password.TableName)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(driver table.Driver, path *fayl.Path) (*sql.DB, *gopolutils.Exception)

Connect to a database of a given driver at a given path. Returns a connection to a database at a given path. If the database can not connect, a gopolutils.KeyError is returned.

Types

type Connector

type Connector func(path *fayl.Path) (*sql.DB, *gopolutils.Exception)

Alias for a callback that returns a connection to database from a given path.

Jump to

Keyboard shortcuts

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