xlsx4db

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 9 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

XLSX for Database

Dump and restore RDBMS by using Excel (XLSX)

PkgGoDev Actions/Go Ask DeepWiki

Usage as a command

$ go install github.com/koron/go-xlsx4db/cmd/xlsx4db@latest
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

Usage as a package

$ go get github.com/koron/go-xlsx4db@latest

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 DumpContext added in v0.0.6

func DumpContext(ctx context.Context, xf *xlsx.File, db *sql.DB, tables ...string) error

DumpContext dumps tables to XLSX file with context.Context.

func FetchTables

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

FetchTables fetches all accessible tables from database.

func FetchTablesContext added in v0.0.6

func FetchTablesContext(ctx context.Context, db *sql.DB) ([]string, error)

FetchTablesContext fetches all accessible tables from database with context.Context.

func Restore

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

Restore restores tables from XLSX file.

func RestoreContext added in v0.0.6

func RestoreContext(ctx context.Context, db *sql.DB, xf *xlsx.File, refresh bool, tables ...string) error

RestoreContext restores tables from XLSX file with context.Context.

func Update

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

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

func UpdateContext added in v0.0.6

func UpdateContext(ctx context.Context, db *sql.DB, xf *xlsx.File, tables ...string) error

UpdateContext updates (UPDATE or INSERT) tables from XLSX file with context.Context.

Types

This section is empty.

Directories

Path Synopsis
cmd
xlsx4db command
examples
check_mysql command
check_psql command
ct command
users command
xlsx_check command
xlsx_dump command
xlsx_restore command

Jump to

Keyboard shortcuts

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