export

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package export queries records for data exports.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrColType  = errors.New("the value type is not usable with the mysql column")
	ErrDB       = errors.New("database handle pointer cannot be nil")
	ErrNoTable  = errors.New("unknown database table")
	ErrMethod   = errors.New("unknown database export type")
	ErrNoMethod = errors.New("no database export type provided")
	ErrPointer  = errors.New("pointer value cannot be nil")
)

Functions

func Tbls

func Tbls() string

Tbls are the available tables in the database.

Example
package main

import (
	"fmt"

	"github.com/Defacto2/df2/pkg/database/internal/export"
)

func main() {
	s := export.Tbls()
	fmt.Print(s)
}
Output:

files, groupnames, netresources

Types

type Flags

type Flags struct {
	Compress bool   // Compress and save the output
	CronJob  bool   // Run in an automated mode
	Parallel bool   // Run --table=all queries in parallel
	Save     bool   // Save the output uncompressed
	Table    Table  // Table of the database to use
	Method   Method // Method to export
	Tables   string // --table flag result
	Type     string // Type of export (create|update)
	Version  string // df2 app version pass-through
	Limit    uint   // Limit the number of records
	SQLDumps string // SQLDumps should be the value of config.SQLDumps
}

Flags are command line arguments.

func (*Flags) DB

func (f *Flags) DB(db *sql.DB, w io.Writer) error

DB saves or prints a MySQL compatible SQL import database statement.

func (*Flags) ExportTable

func (f *Flags) ExportTable(db *sql.DB, w io.Writer) error

ExportTable saves or prints a MySQL compatible SQL import table statement.

func (*Flags) Run

func (f *Flags) Run(db *sql.DB, w io.Writer) error

Run is intended for an operating system time-based job scheduler. It creates both create and update types exports for the files table.

type Method

type Method int

Method to interact with the database.

const (
	Create Method = iota // Create uses the CREATE SQL statement to make a new record.
	Insert               // Insert uses the UPDATE SQL statement to edit an existing record.
)

func (Method) String

func (m Method) String() string

type Table

type Table int

A database table.

Example
package main

import (
	"fmt"

	"github.com/Defacto2/df2/pkg/database/internal/export"
)

func main() {
	fmt.Print(export.Files)
}
Output:

files
const (
	Files        Table = iota // Files records.
	Groups                    // Groups names.
	Netresources              // Netresources for online websites.
)

func (Table) String

func (t Table) String() string

Jump to

Keyboard shortcuts

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