Documentation ¶
Overview ¶
Package mysqltsv encodes values for usage in LOAD DATA INFILE's tab separated values.
Index ¶
Constants ¶
const Escaping = `` /* 129-byte string literal not displayed */
Escaping explains the escaping this package uses for inclusion in a LOAD DATA INFILE statement.
Variables ¶
This section is empty.
Functions ¶
func EscapeValue ¶
func EscapeValue(v any, cfg *EncoderOptions) ([]byte, error)
EscapeValue escapes a value for use in a MySQL CSV. It's escaped as shown in the constant Escaping. EncoderOptions is optional.
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder encodes values into a CSV file suitable for consumption by LOAD DATA INFILE. The number of columns per row must be fixed, and it will automatically advance to the next row once all columns were appended. Any errors during appending will be stored and future calls will be ignored. The encoder must be Close()d once done to flush and to read any errors that might have occurred.
func NewEncoder ¶
func NewEncoder(w io.Writer, numColumns int, cfg *EncoderOptions) *Encoder
NewEncoder starts a new encoder. You should write the same number of columns per line and the Encoder will decide when a row is finished. Close must be called to see if any error occurred. EncoderOptions is optional.
func (*Encoder) AppendBytes ¶
func (*Encoder) AppendString ¶
func (*Encoder) AppendValue ¶
type EncoderOptions ¶
type EncoderOptions struct { // Location is the timezone each time.Time will be converted to before being serialized. Location *time.Location }
EncoderOptions are settings that affect encoding.