storage

package
v0.0.0-...-e6545d5 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SQLite3Options

type SQLite3Options struct{}

SQLite3Options are options passed into SQLite3 connection as needed.

type SQLite3Storage

type SQLite3Storage struct {
	// contains filtered or unexported fields
}

SQLite3Storage represents a TextQL compatible SQL backend based on in-memory SQLite3

func NewSQLite3Storage

func NewSQLite3Storage(opts *SQLite3Options) *SQLite3Storage

NewSQLite3Storage returns a SQLite3Storage with the SQLite3Options provided applied.

func NewSQLite3StorageWithDefaults

func NewSQLite3StorageWithDefaults() *SQLite3Storage

NewSQLite3StorageWithDefaults returns a SQLite3Storage with the default options.

func (*SQLite3Storage) Close

func (sqlite3Storage *SQLite3Storage) Close()

Close will close the current database

func (*SQLite3Storage) Exec

func (sqlite3Storage *SQLite3Storage) Exec(sqlQuery string) (sql.Result, error)

Exec maps the sqlQuery provided from short hand TextQL to SQL, then applies the query to the sqlite3 in memory database, and lastly returns the sql.Result that resulted from the executing query.

func (*SQLite3Storage) ExecuteSQLString

func (sqlite3Storage *SQLite3Storage) ExecuteSQLString(sqlQuery string) (*sql.Rows, error)

ExecuteSQLString maps the sqlQuery provided from short hand TextQL to SQL, then applies the query to the sqlite3 in memory database, and lastly returns the sql.Rows that resulted from the executing query.

func (*SQLite3Storage) LoadInput

func (sqlite3Storage *SQLite3Storage) LoadInput(input inputs.Input)

LoadInput reads the entire Input provided into a table named after the Input name. The name is cooreced into a valid SQLite3 table name prior to use.

func (*SQLite3Storage) SaveTo

func (sqlite3Storage *SQLite3Storage) SaveTo(path string) error

SaveTo saves the current in memory database to the path provided as a string.

type Storage

type Storage interface {
	// LoadInput should make all the data in the input accessible to queries.
	LoadInput(*inputs.Input)
	// SaveTo should write the entire database of the SQL backend to the path given as a string.
	// Failure in any way should return an error, and nil if the operation was successful.
	SaveTo(string) error
	// ExecuteSQLString should first convert from TextQL shorthand SQL to normal SQL,
	// apply the query or transformation given to the SQL backend and return either nil
	// or the sql.Rows that were returned from the query.
	ExecuteSQLString(string) (*sql.Rows, error)
	// Close should cleanly close the database backend, cleaning up data on disk if required.
	Close()
}

Storage implentors are expected to be SQL capable engines. A Storage should support loading data from a TextQL input, executing any number of SQL statements and returning their resultant sql.Rows, as well as supporting clean closing and "backing up" of data to a specific path

Jump to

Keyboard shortcuts

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