File: storage.go

package info (click to toggle)
textql 2.0.3-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,256 kB
  • sloc: yacc: 962; makefile: 45
file content (26 lines) | stat: -rw-r--r-- 1,065 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package storage

import (
	"database/sql"

	"github.com/dinedal/textql/inputs"
)

// 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
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
	// Close should cleanly close the database backend, cleaning up data on disk if required.
	Close()
}