exporter

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportCSV

func ExportCSV(w io.Writer, rs *engine.ResultSet, opts Options) error

ExportCSV writes ResultSet rows as CSV to w. Column order is preserved.

func ExportGOB

func ExportGOB(w io.Writer, rs *engine.ResultSet) error

ExportGOB encodes the ResultSet.Rows using gob to w.

func ExportJSON

func ExportJSON(w io.Writer, rs *engine.ResultSet, opts Options) error

ExportJSON writes ResultSet rows as a JSON array of objects.

func ExportNDJSON added in v0.19.0

func ExportNDJSON(w io.Writer, rs *engine.ResultSet, opts Options) error

ExportNDJSON writes one JSON object per ResultSet row. Unlike ExportJSON it does not materialize a result-sized array, so it is suitable for pipes and large exports. Each line is independently valid JSON.

func ExportSQL added in v0.14.0

func ExportSQL(w io.Writer, rs *engine.ResultSet, tableName string) error

ExportSQL writes ResultSet rows as INSERT statements for tableName.

func ExportTableManifest added in v0.19.0

func ExportTableManifest(w io.Writer, db *storage.DB, tenant, tableName string) error

ExportTableManifest writes a deterministic JSON schema and data fingerprint for one table. The corresponding data can be exported as CSV, JSON or SQL.

func ExportXML

func ExportXML(w io.Writer, rs *engine.ResultSet) error

ExportXML writes ResultSet as simple XML: <rows><row><col>value</col>...</row>...</rows>

Types

type ManifestColumn added in v0.19.0

type ManifestColumn struct {
	Name         string `json:"name"`
	DeclaredType string `json:"declared_type"`
	Affinity     string `json:"affinity,omitempty"`
	NotNull      bool   `json:"not_null"`
	HasDefault   bool   `json:"has_default"`
	DefaultSQL   string `json:"default_sql,omitempty"`
	Constraint   string `json:"constraint,omitempty"`
}

ManifestColumn preserves portable schema information without exposing tinySQL internal implementation fields.

type Options

type Options struct {
	PrettyJSON   bool
	CSVNoHeader  bool
	CSVDelimiter rune
	// BinaryEncoding controls CSV rendering of BLOB values. "base64" is the
	// default and writes a self-identifying base64: payload; "hex" writes a
	// self-identifying hex: payload. SQL always uses SQLite-compatible X'..'.
	BinaryEncoding string
	// JSONBinaryEnvelope preserves the BLOB/text distinction in JSON by
	// encoding BLOBs as {"$tinysql":"blob","base64":"..."}. It is enabled
	// by default; set JSONBinaryMode to "legacy-string" for a plain base64
	// string compatible with encoding/json's historical []byte behaviour.
	JSONBinaryMode string
}

Options controls exporter behavior.

type TableManifest added in v0.19.0

type TableManifest struct {
	FormatVersion int              `json:"format_version"`
	Tenant        string           `json:"tenant"`
	Table         string           `json:"table"`
	TextEncoding  string           `json:"text_encoding"`
	RowCount      int              `json:"row_count"`
	DataSHA256    string           `json:"data_sha256"`
	Columns       []ManifestColumn `json:"columns"`
}

TableManifest is a portable, versioned description of an exported table. DataSHA256 fingerprints the ordered rows and typed cells without exposing their contents. It allows an import/export workflow to verify parity before publishing an artifact.

Jump to

Keyboard shortcuts

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