json_to_sql

command
v1.4.7-1a7fcad7aeec560... Latest Latest
Warning

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

Go to latest
Published: May 15, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

README

JSON to SQL

This directory contains a small go script that consumes single-layer .json files from stdin and outputs them as SQL INSERT statements. Each field in each record of the input is converted to a column name, and the value of that field is written to that column.

The binary takes a single argument: the name of the table that the data should be written to. For example:

$ go build to_sql.go && cat test.json | ./to_sql cars
INSERT INTO cars (year, make, model) VALUES (2005, Toyota, Corolla);
INSERT INTO cars (model, year, make) VALUES (Civic, 1998, Honda);
INSERT INTO cars (make, model, year) VALUES (Tesla, Roadster, 2008);
INSERT INTO cars (make, model, year) VALUES (Bugatti, Chiron, 2016);
INSERT INTO cars (make, model, year) VALUES (Dodge, Viper, 2015);

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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