Documentation
¶
Overview ¶
Package exporter exposes stable result export helpers backed by tinySQL's internal exporter implementation.
Index ¶
- func ExportCSV(w io.Writer, rs *tinysql.ResultSet, opts Options) error
- func ExportGOB(w io.Writer, rs *tinysql.ResultSet) error
- func ExportJSON(w io.Writer, rs *tinysql.ResultSet, opts Options) error
- func ExportNDJSON(w io.Writer, rs *tinysql.ResultSet, opts Options) error
- func ExportSQL(w io.Writer, rs *tinysql.ResultSet, tableName string) error
- func ExportTSV(w io.Writer, rs *tinysql.ResultSet, opts Options) error
- func ExportTableManifest(w io.Writer, db *tinysql.DB, tenant, tableName string) error
- func ExportXML(w io.Writer, rs *tinysql.ResultSet) error
- type ManifestColumn
- type Options
- type TableManifest
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportJSON ¶
ExportJSON writes ResultSet rows as a JSON array of objects.
Example ¶
package main
import (
"bytes"
"fmt"
tinysql "github.com/SimonWaldherr/tinySQL"
"github.com/SimonWaldherr/tinySQL/exporter"
)
// jsonExampleResult gives the example a named package-level fixture while
// keeping the usage of ExportJSON concise.
var jsonExampleResult = &tinysql.ResultSet{
Cols: []string{"id", "name"},
Rows: []tinysql.Row{{"id": 1, "name": "Ada"}},
}
func main() {
var out bytes.Buffer
if err := exporter.ExportJSON(&out, jsonExampleResult, exporter.Options{}); err != nil {
panic(err)
}
fmt.Print(out.String())
}
Output: [{"id":1,"name":"Ada"}]
func ExportNDJSON ¶ added in v0.19.0
ExportNDJSON streams one JSON object per ResultSet row to w.
func ExportSQL ¶ added in v0.14.0
ExportSQL writes ResultSet rows as INSERT statements for tableName.
func ExportTableManifest ¶ added in v0.19.0
ExportTableManifest writes a versioned table schema and data fingerprint.
Types ¶
type ManifestColumn ¶ added in v0.19.0
type ManifestColumn = ie.ManifestColumn
ManifestColumn describes one column in a TableManifest.
type TableManifest ¶ added in v0.19.0
type TableManifest = ie.TableManifest
TableManifest is the portable table schema and data-fingerprint document.
Click to show internal directories.
Click to hide internal directories.