xlsx4db

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 8 Imported by: 1

README

XLSX for Database

Dump and restore RDBMS by using Excel (XLSX)

GoDoc Actions/Go Go Report Card

Usage

$ go get github.com/koron/go-xlsx4db/cmd/xlsx4db
Options
$ ./xlsx4db -h
Usage of xlsx4db:
  -dbname string
        DB source string, example:
          * MySQL: "{user}:{pass}@{addr}/{name}"
          * PostgreSQL: "postgres://{user}:{pass}@{addr}/{name}?sslmode=disable"
  -driver string
        DB driver: "mysql" or "postgres"
  -mode string
        Mode: "dump" or "restore"
  -tables string
        OPTION: table names to dump/restore
  -xlsx string
        Excel file name to operate

Tips

Tips in Japanese
  • 値を NULL にするには

    セルの内容を (NULL) とし、背景を白以外の色で塗りつぶす。

Tips in English
  • How to make a column NULL

    Make a cell content as (NULL) and fill background with the color except white.

Misc

  • How does retrieve table names?

    • PostgreSQL: SELECT relname FROM pg_stat_user_tables
    • MySQL: SHOW TABLES or SHOW TABLES FROM {db_name}
  • What dbname does MySQL accept?

    • vagrant:db1234@tcp(127.0.0.1:3306)/vagrant

Documentation

Overview

Package xlsx4db provides dump and restore features by using Excel (XLSX) format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildInsertQuery

func BuildInsertQuery(db *sql.DB, table string, columns []string) (string, error)

BuildInsertQuery builds na insert statement with given columns.

func BuildUpsertQuery

func BuildUpsertQuery(db *sql.DB, table string, columns []string) (string, error)

BuildUpsertQuery builds "insert or update" statement with given params.

func Dump

func Dump(xf *xlsx.File, db *sql.DB, tables ...string) error

Dump dumps tables to XLSX file.

func FetchTables

func FetchTables(db *sql.DB) ([]string, error)

FetchTables fetches all accessible tables from database.

func Restore

func Restore(db *sql.DB, xf *xlsx.File, refresh bool, tables ...string) error

Restore restores tables from XLSX file.

func Update

func Update(db *sql.DB, xf *xlsx.File, tables ...string) error

Update updates (UPDATE or INSERT) tables from XLSX file.

Types

This section is empty.

Directories

Path Synopsis
cmd
examples
ct

Jump to

Keyboard shortcuts

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