From 07120ad8ad4d96e8adaf7f36f1f10f0583caac16 Mon Sep 17 00:00:00 2001 From: "R. S. Doiel" Date: Thu, 5 Jan 2023 14:45:17 -0800 Subject: [PATCH] feat: sql2csv release prep --- README.md | 3 +- codemeta2cff.1.html | 97 ++++++++++++++++++ codemeta2cff.1.md | 8 +- index.html | 6 +- man/man1/codemeta2cff.1 | 2 +- man/man1/sql2csv.1 | 2 +- sql2csv.1.html | 213 ++++++++++++++++++++++++++++++++++++++++ sql2csv.1.md | 8 +- 8 files changed, 329 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9d7b692..8b2c282 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ Excel Workbooks and plain text files or content. + [xlsx2csv](docs/xlsx2csv/) - a tool for converting Excel Workbooks sheets to CSV files + [xlsx2json](docs/xlsx2json/) - a tool for converting Excel Workbooks to JSON files + [yaml2json](docs/yaml2json/) - a tool for converting YAML files to JSON -+ [codemeta2cff](docs/codemeta2cff) - a tool to convert a codemeta.json file into a CITATION.cff file. ++ [codemeta2cff](codemeta2cff.1.md) - a tool to convert a codemeta.json file into a CITATION.cff file. ++ [sql2csv](sql2csv.1.html) - a tool to execute a SQL query in MySQL or SQLIte3 and render the results in CSV encoding Compiled versions are provided for Linux (amd64), Mac OS X (amd64), diff --git a/codemeta2cff.1.html b/codemeta2cff.1.html index e69de29..3096d8e 100644 --- a/codemeta2cff.1.html +++ b/codemeta2cff.1.html @@ -0,0 +1,97 @@ + + + + Caltech Library's Digital Library Development Sandbox + + + + +
+Caltech Library logo +
+ + +
+

+NAME +

+

+codemeta2cff +

+

+SYSNOPSIS +

+

+codemeta2cff OPTIONS [CODEMETA_JSON CITATION_CFF] +

+

+DESCRIPTION +

+

+Reads codemeta.json file and writes CITATION.cff. By default it assume +both are in the current directory. You can also provide the name and +path to both files. +

+

+OPTIONS +

+
+
+-help +
+
+display help +
+
+

+EXAMPLE +

+

+Generating the CITATION.cff from the codemeta.json file the current +working directory. +

+
codemeta2cff
+

+Specifying the full paths. +

+
codemeta2cff /opt/local/myproject/codemeta.json /opt/local/myproject/CITATION.cff
+
+ + + + diff --git a/codemeta2cff.1.md b/codemeta2cff.1.md index 8c6a0b1..ef619d7 100644 --- a/codemeta2cff.1.md +++ b/codemeta2cff.1.md @@ -1,6 +1,8 @@ -% codemeta2cff(1) user manual -% R. S. Doiel -% 2022-10-28 +--- +title: "codemeta2cff(1) user manual" +author: "R. S. Doiel" +pubDate: "2022-10-28" +--- # NAME diff --git a/index.html b/index.html index d7ddf7d..528d6cd 100644 --- a/index.html +++ b/index.html @@ -139,9 +139,13 @@

files to JSON
  • -codemeta2cff - a tool to convert a +codemeta2cff - a tool to convert a codemeta.json file into a CITATION.cff file.
  • +
  • +sql2csv - a tool to execute a SQL query in +MySQL or SQLIte3 and render the results in CSV encoding +
  • Compiled versions are provided for Linux (amd64), Mac OS X (amd64), diff --git a/man/man1/codemeta2cff.1 b/man/man1/codemeta2cff.1 index 9efa52e..9a4a327 100644 --- a/man/man1/codemeta2cff.1 +++ b/man/man1/codemeta2cff.1 @@ -14,7 +14,7 @@ . ftr VB CB . ftr VBI CBI .\} -.TH "codemeta2cff" "1" "2022-10-28" "user manual" "" +.TH "codemeta2cff" "1" "" "user manual" "" .hy .SH NAME .PP diff --git a/man/man1/sql2csv.1 b/man/man1/sql2csv.1 index f29e1e8..f5fec3d 100644 --- a/man/man1/sql2csv.1 +++ b/man/man1/sql2csv.1 @@ -14,7 +14,7 @@ . ftr VB CB . ftr VBI CBI .\} -.TH "sql2csv (1) user manual" "" "2023-01-03" "" "" +.TH "sql2csv (1) user manual" "" "" "" "" .hy .SH NAME .PP diff --git a/sql2csv.1.html b/sql2csv.1.html index e69de29..9829f62 100644 --- a/sql2csv.1.html +++ b/sql2csv.1.html @@ -0,0 +1,213 @@ + + + + Caltech Library's Digital Library Development Sandbox + + + + +

    +Caltech Library logo +
    + + +
    +

    +NAME +

    +

    +sql2csv +

    +

    +SYNOPSIS +

    +

    +sql2csv OPTIONS SQL_STATEMENT +

    +

    +sql2csv OPTIONS CONFIG_FILE SQL_STATEMENT +

    +

    +DESCRIPTION +

    +

    +sql2csv takes a config file describing a SQL database connection and +output options needed and a SQL statement as the final parameter. The +output of the SQL query is rendered in CSV format to standard out. +sql2csv supports querying MySQL 8, Postgres and SQLite3 databases. +

    +

    +The configuration file is a JSON document with the following key value +pairs. +

    +
    +
    +dsn_url +
    +
    +(string) A data source name in URL form where the “protocol” element +identifies the database resource being accessed (e.g. “sqlite://”, +“mysql://”, “postgres://”). A data source name are rescribed at https://github.com/golang/go/wiki/SQLInterface. +
    +
    +header_row +
    +
    +(boolean) if true print a header row in the output, false for no header +row output +
    +
    +delimiter +
    +
    +(single character, default is “,”), sets the field delimited used in +output. It can be set to “ for tab separated values. +
    +
    +use_crlf +
    +
    +(boolean, default is false) if set to true to use “” as the line +terminator between rows of output. +
    +
    +

    +To connect with a database sql2csv relies on a data source name (DSN) in +URL format. In the URL form the URL’s scheme indicates the type of +database you are connecting to (e.g. sqlite, mysql, postgres). The rest +of the DNS has the following form +

    +
    [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]
    +

    +For a simple database like SQLite3 a minimal DSN in url form for a +database file “my_database.sqlite3” would look like +

    +
        sqlite://file:my_database.sqlite3
    +

    +For MySQL you need to provide more information to connect +(e.g. username, password). In this example the username is “jane.doe”, +password is “something_secret” the database is “my_database”. (this +example assumes that MySQL 8 is running on localhost at the usual port). +

    +
        mysql://jane.doe:something_secret@/my_database
    +

    +Postgres is similar to the MySQL connection string except the “scheme” +is “postgres” instead of “mysql”. +

    +

    +OPTIONS +

    +
    +
    +-help +
    +
    +display help +
    +
    +-version +
    +
    +display version +
    +
    +-license +
    +
    +display license +
    +
    +

    +A the following options will override a configuration. +

    +
    +
    +-dsn +
    +
    +use the data source name in URL form instead of a JSON configuration +file +
    +
    +-header +
    +
    +use a header row if true, false skip the header row +
    +
    +-delimiter +
    +
    +Set the delimiter to use, default is comma +
    +
    +-use-cdlf +
    +
    +Force the line ending per row to carage return and line feed if true, +false use line feed +
    +
    +

    +EXAMPLE +

    +

    +Using the “dbcfg.json” configuration file, display ten rows from table +“mytable” in database indicated in “dbcfg.json”. +

    +

    +sql2csv dbcfg.json ‘SELECT * FROM mytable LIMIT 10’ +

    +

    +The CSV output is written standard out and can be redirected into a file +if desired. +

    +

    +sql2csv dbcfg.json ‘SELECT * FROM mytable LIMIT 10’
    +>ten-rows.csv +

    +

    +sql2csv 1.1.5 +

    +
    + + + + diff --git a/sql2csv.1.md b/sql2csv.1.md index 543d1dd..7bb35dd 100644 --- a/sql2csv.1.md +++ b/sql2csv.1.md @@ -1,6 +1,8 @@ -% sql2csv (1) user manual -% R. S. Doiel -% 2023-01-03 +--- +title: "sql2csv (1) user manual" +author: "R. S. Doiel" +pubDate: 2023-01-05 +--- # NAME