Documentation
¶
Index ¶
- func ExportCSV(w io.Writer, rs *engine.ResultSet, opts Options) error
- func ExportGOB(w io.Writer, rs *engine.ResultSet) error
- func ExportJSON(w io.Writer, rs *engine.ResultSet, opts Options) error
- func ExportNDJSON(w io.Writer, rs *engine.ResultSet, opts Options) error
- func ExportSQL(w io.Writer, rs *engine.ResultSet, tableName string) error
- func ExportTableManifest(w io.Writer, db *storage.DB, tenant, tableName string) error
- func ExportXML(w io.Writer, rs *engine.ResultSet) error
- type ManifestColumn
- type Options
- type TableManifest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportJSON ¶
ExportJSON writes ResultSet rows as a JSON array of objects. Like ExportNDJSON, it encodes one row at a time instead of materializing a result-sized []map[string]any, so memory use stays proportional to a single row rather than the whole result set. The bytes written are identical to json.Encoder (with the same PrettyJSON setting) encoding that materialized slice in one call.
func ExportNDJSON ¶ added in v0.19.0
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
ExportSQL writes ResultSet rows as INSERT statements for tableName.
func ExportTableManifest ¶ added in v0.19.0
ExportTableManifest writes a deterministic JSON schema and data fingerprint for one table. The corresponding data can be exported as CSV, JSON or SQL.
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.