Skip to content

Commit

Permalink
feat: sql2csv release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdoiel committed Jan 5, 2023
1 parent 621fa3b commit 07120ad
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 10 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
97 changes: 97 additions & 0 deletions codemeta2cff.1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!DOCTYPE html>
<html>
<head>
<title>Caltech Library's Digital Library Development Sandbox</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/css/site.css">
</head>
<body>
<header>
<a href="http://library.caltech.edu"><img src="/assets/liblogo.gif" alt="Caltech Library logo"></a>
</header>
<nav>
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="index.html">README</a>
</li>
<li>
<a href="license.html">LICENSE</a>
</li>
<li>
<a href="install.html">INSTALL</a>
</li>
<li>
<a href="docs/">Documentation</a>
</li>
<li>
<a href="how-to/">How To</a>
</li>
<li>
<a href="about.html">About</a>
</li>
<li>
<a
href="https://github.com/caltechlibrary/datatools">Github</a>
</li>
</ul>
</nav>

<section>
<h1 id="name">
NAME
</h1>
<p>
codemeta2cff
</p>
<h1 id="sysnopsis">
SYSNOPSIS
</h1>
<p>
codemeta2cff <a href="#options">OPTIONS</a> [CODEMETA_JSON CITATION_CFF]
</p>
<h1 id="description">
DESCRIPTION
</h1>
<p>
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.
</p>
<h1 id="options">
OPTIONS
</h1>
<dl>
<dt>
-help
</dt>
<dd>
display help
</dd>
</dl>
<h1 id="example">
EXAMPLE
</h1>
<p>
Generating the CITATION.cff from the codemeta.json file the current
working directory.
</p>
<pre><code>codemeta2cff</code></pre>
<p>
Specifying the full paths.
</p>
<pre><code>codemeta2cff /opt/local/myproject/codemeta.json /opt/local/myproject/CITATION.cff</code></pre>
</section>

<footer>
<span><h1><A href="http://caltech.edu">Caltech</a></h1></span>
<span>&copy; 2021 <a href="https://www.library.caltech.edu/copyright">Caltech library</a></span>
<address>1200 E California Blvd, Mail Code 1-32, Pasadena, CA 91125-3200</address>
<span>Phone: <a href="tel:+1-626-395-3405">(626)395-3405</a></span>
<span><a href="mailto:[email protected]">Email Us</a></span>
<a class="cl-hide" href="sitemap.xml">Site Map</a>
</footer>
</body>
</html>
8 changes: 5 additions & 3 deletions codemeta2cff.1.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,13 @@ <h2 id="for-data">
files to JSON
</li>
<li>
<a href="docs/codemeta2cff">codemeta2cff</a> - a tool to convert a
<a href="codemeta2cff.1.md">codemeta2cff</a> - a tool to convert a
codemeta.json file into a CITATION.cff file.
</li>
<li>
<a href="sql2csv.1.html">sql2csv</a> - a tool to execute a SQL query in
MySQL or SQLIte3 and render the results in CSV encoding
</li>
</ul>
<p>
Compiled versions are provided for Linux (amd64), Mac OS X (amd64),
Expand Down
2 changes: 1 addition & 1 deletion man/man1/codemeta2cff.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion man/man1/sql2csv.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
213 changes: 213 additions & 0 deletions sql2csv.1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
<!DOCTYPE html>
<html>
<head>
<title>Caltech Library's Digital Library Development Sandbox</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/css/site.css">
</head>
<body>
<header>
<a href="http://library.caltech.edu"><img src="/assets/liblogo.gif" alt="Caltech Library logo"></a>
</header>
<nav>
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="index.html">README</a>
</li>
<li>
<a href="license.html">LICENSE</a>
</li>
<li>
<a href="install.html">INSTALL</a>
</li>
<li>
<a href="docs/">Documentation</a>
</li>
<li>
<a href="how-to/">How To</a>
</li>
<li>
<a href="about.html">About</a>
</li>
<li>
<a
href="https://github.com/caltechlibrary/datatools">Github</a>
</li>
</ul>
</nav>

<section>
<h1 id="name">
NAME
</h1>
<p>
sql2csv
</p>
<h1 id="synopsis">
SYNOPSIS
</h1>
<p>
sql2csv <a href="#options">OPTIONS</a> SQL_STATEMENT
</p>
<p>
sql2csv <a href="#options">OPTIONS</a> CONFIG_FILE SQL_STATEMENT
</p>
<h1 id="description">
DESCRIPTION
</h1>
<p>
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.
</p>
<p>
The configuration file is a JSON document with the following key value
pairs.
</p>
<dl>
<dt>
dsn_url
</dt>
<dd>
(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 <a
href="https://github.com/golang/go/wiki/SQLInterface"
class="uri">https://github.com/golang/go/wiki/SQLInterface</a>.
</dd>
<dt>
header_row
</dt>
<dd>
(boolean) if true print a header row in the output, false for no header
row output
</dd>
<dt>
delimiter
</dt>
<dd>
(single character, default is “,”), sets the field delimited used in
output. It can be set to “ for tab separated values.
</dd>
<dt>
use_crlf
</dt>
<dd>
(boolean, default is false) if set to true to use “” as the line
terminator between rows of output.
</dd>
</dl>
<p>
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
</p>
<pre><code>[username[:password]@][protocol[(address)]]/dbname[?param1=value1&amp;...&amp;paramN=valueN]</code></pre>
<p>
For a simple database like SQLite3 a minimal DSN in url form for a
database file “my_database.sqlite3” would look like
</p>
<pre><code> sqlite://file:my_database.sqlite3</code></pre>
<p>
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).
</p>
<pre><code> mysql://jane.doe:something_secret@/my_database</code></pre>
<p>
Postgres is similar to the MySQL connection string except the “scheme”
is “postgres” instead of “mysql”.
</p>
<h1 id="options">
OPTIONS
</h1>
<dl>
<dt>
-help
</dt>
<dd>
display help
</dd>
<dt>
-version
</dt>
<dd>
display version
</dd>
<dt>
-license
</dt>
<dd>
display license
</dd>
</dl>
<p>
A the following options will override a configuration.
</p>
<dl>
<dt>
-dsn
</dt>
<dd>
use the data source name in URL form instead of a JSON configuration
file
</dd>
<dt>
-header
</dt>
<dd>
use a header row if true, false skip the header row
</dd>
<dt>
-delimiter
</dt>
<dd>
Set the delimiter to use, default is comma
</dd>
<dt>
-use-cdlf
</dt>
<dd>
Force the line ending per row to carage return and line feed if true,
false use line feed
</dd>
</dl>
<h1 id="example">
EXAMPLE
</h1>
<p>
Using the “dbcfg.json” configuration file, display ten rows from table
“mytable” in database indicated in “dbcfg.json”.
</p>
<p>
sql2csv dbcfg.json ‘SELECT * FROM mytable LIMIT 10’
</p>
<p>
The CSV output is written standard out and can be redirected into a file
if desired.
</p>
<p>
sql2csv dbcfg.json ‘SELECT * FROM mytable LIMIT 10’<br />
&gt;ten-rows.csv
</p>
<p>
sql2csv 1.1.5
</p>
</section>

<footer>
<span><h1><A href="http://caltech.edu">Caltech</a></h1></span>
<span>&copy; 2021 <a href="https://www.library.caltech.edu/copyright">Caltech library</a></span>
<address>1200 E California Blvd, Mail Code 1-32, Pasadena, CA 91125-3200</address>
<span>Phone: <a href="tel:+1-626-395-3405">(626)395-3405</a></span>
<span><a href="mailto:[email protected]">Email Us</a></span>
<a class="cl-hide" href="sitemap.xml">Site Map</a>
</footer>
</body>
</html>
8 changes: 5 additions & 3 deletions sql2csv.1.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 07120ad

Please sign in to comment.