csv2sqlite

package module
v0.0.0-...-09ec2d6 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: MIT Imports: 7 Imported by: 0

README

csv2sqlite

CLI tool to convert csv to sqlite with type info

Usage

Run with options (single table)

$ csv2sqlite -c ./foo.csv -t foo_tb -d ./dump.db
foo.csv -> dump.db (incl. foo_tb)

Run with options (multiple tables)

$ csv2sqlite -c ./foo.csv -t foo_tb -c ./bar.csv -t bar_tb -d ./dump.db
(foo.csv, bar.csv) -> dump.db (incl. foo_tb, bar_tb)

Run with no options (only single table)

$ csv2sqlite ./foo.csv
foo.csv -> foo.db (incl. foo)

Useful in combination with drag-and-drop or shortcuts

Installation

$ go install github.com/dono/csv2sqlite/cmd/csv2sqlite@latest

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenTableQParams

func GenTableQParams(scheme string) string

func GenTableScheme

func GenTableScheme(header []string, sampleRow []string) string

TODO: escape "(", ")", ",", and so on.

Types

type DB

type DB struct {
	*sql.DB
}

func NewDB

func NewDB(dbName string) (*DB, error)

func (*DB) CreateTable

func (db *DB) CreateTable(name string, scheme string) (Table, error)

type Table

type Table struct {
	*DB
	Name    string
	Scheme  string
	QParams string
}

func (Table) InsertRows

func (table Table) InsertRows(rows [][]string) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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