Skip to content

Commit 07120ad

Browse files
committed
feat: sql2csv release prep
1 parent 621fa3b commit 07120ad

File tree

8 files changed

+329
-10
lines changed

8 files changed

+329
-10
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ Excel Workbooks and plain text files or content.
3333
+ [xlsx2csv](docs/xlsx2csv/) - a tool for converting Excel Workbooks sheets to CSV files
3434
+ [xlsx2json](docs/xlsx2json/) - a tool for converting Excel Workbooks to JSON files
3535
+ [yaml2json](docs/yaml2json/) - a tool for converting YAML files to JSON
36-
+ [codemeta2cff](docs/codemeta2cff) - a tool to convert a codemeta.json file into a CITATION.cff file.
36+
+ [codemeta2cff](codemeta2cff.1.md) - a tool to convert a codemeta.json file into a CITATION.cff file.
37+
+ [sql2csv](sql2csv.1.html) - a tool to execute a SQL query in MySQL or SQLIte3 and render the results in CSV encoding
3738

3839

3940
Compiled versions are provided for Linux (amd64), Mac OS X (amd64),

codemeta2cff.1.html

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Caltech Library's Digital Library Development Sandbox</title>
5+
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
6+
<link rel="stylesheet" href="/css/site.css">
7+
</head>
8+
<body>
9+
<header>
10+
<a href="http://library.caltech.edu"><img src="/assets/liblogo.gif" alt="Caltech Library logo"></a>
11+
</header>
12+
<nav>
13+
<ul>
14+
<li>
15+
<a href="/">Home</a>
16+
</li>
17+
<li>
18+
<a href="index.html">README</a>
19+
</li>
20+
<li>
21+
<a href="license.html">LICENSE</a>
22+
</li>
23+
<li>
24+
<a href="install.html">INSTALL</a>
25+
</li>
26+
<li>
27+
<a href="docs/">Documentation</a>
28+
</li>
29+
<li>
30+
<a href="how-to/">How To</a>
31+
</li>
32+
<li>
33+
<a href="about.html">About</a>
34+
</li>
35+
<li>
36+
<a
37+
href="https://github.com/caltechlibrary/datatools">Github</a>
38+
</li>
39+
</ul>
40+
</nav>
41+
42+
<section>
43+
<h1 id="name">
44+
NAME
45+
</h1>
46+
<p>
47+
codemeta2cff
48+
</p>
49+
<h1 id="sysnopsis">
50+
SYSNOPSIS
51+
</h1>
52+
<p>
53+
codemeta2cff <a href="#options">OPTIONS</a> [CODEMETA_JSON CITATION_CFF]
54+
</p>
55+
<h1 id="description">
56+
DESCRIPTION
57+
</h1>
58+
<p>
59+
Reads codemeta.json file and writes CITATION.cff. By default it assume
60+
both are in the current directory. You can also provide the name and
61+
path to both files.
62+
</p>
63+
<h1 id="options">
64+
OPTIONS
65+
</h1>
66+
<dl>
67+
<dt>
68+
-help
69+
</dt>
70+
<dd>
71+
display help
72+
</dd>
73+
</dl>
74+
<h1 id="example">
75+
EXAMPLE
76+
</h1>
77+
<p>
78+
Generating the CITATION.cff from the codemeta.json file the current
79+
working directory.
80+
</p>
81+
<pre><code>codemeta2cff</code></pre>
82+
<p>
83+
Specifying the full paths.
84+
</p>
85+
<pre><code>codemeta2cff /opt/local/myproject/codemeta.json /opt/local/myproject/CITATION.cff</code></pre>
86+
</section>
87+
88+
<footer>
89+
<span><h1><A href="http://caltech.edu">Caltech</a></h1></span>
90+
<span>&copy; 2021 <a href="https://www.library.caltech.edu/copyright">Caltech library</a></span>
91+
<address>1200 E California Blvd, Mail Code 1-32, Pasadena, CA 91125-3200</address>
92+
<span>Phone: <a href="tel:+1-626-395-3405">(626)395-3405</a></span>
93+
<span><a href="mailto:[email protected]">Email Us</a></span>
94+
<a class="cl-hide" href="sitemap.xml">Site Map</a>
95+
</footer>
96+
</body>
97+
</html>

codemeta2cff.1.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
% codemeta2cff(1) user manual
2-
% R. S. Doiel
3-
% 2022-10-28
1+
---
2+
title: "codemeta2cff(1) user manual"
3+
author: "R. S. Doiel"
4+
pubDate: "2022-10-28"
5+
---
46

57
# NAME
68

index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,13 @@ <h2 id="for-data">
139139
files to JSON
140140
</li>
141141
<li>
142-
<a href="docs/codemeta2cff">codemeta2cff</a> - a tool to convert a
142+
<a href="codemeta2cff.1.md">codemeta2cff</a> - a tool to convert a
143143
codemeta.json file into a CITATION.cff file.
144144
</li>
145+
<li>
146+
<a href="sql2csv.1.html">sql2csv</a> - a tool to execute a SQL query in
147+
MySQL or SQLIte3 and render the results in CSV encoding
148+
</li>
145149
</ul>
146150
<p>
147151
Compiled versions are provided for Linux (amd64), Mac OS X (amd64),

man/man1/codemeta2cff.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
. ftr VB CB
1515
. ftr VBI CBI
1616
.\}
17-
.TH "codemeta2cff" "1" "2022-10-28" "user manual" ""
17+
.TH "codemeta2cff" "1" "" "user manual" ""
1818
.hy
1919
.SH NAME
2020
.PP

man/man1/sql2csv.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
. ftr VB CB
1515
. ftr VBI CBI
1616
.\}
17-
.TH "sql2csv (1) user manual" "" "2023-01-03" "" ""
17+
.TH "sql2csv (1) user manual" "" "" "" ""
1818
.hy
1919
.SH NAME
2020
.PP

sql2csv.1.html

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Caltech Library's Digital Library Development Sandbox</title>
5+
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
6+
<link rel="stylesheet" href="/css/site.css">
7+
</head>
8+
<body>
9+
<header>
10+
<a href="http://library.caltech.edu"><img src="/assets/liblogo.gif" alt="Caltech Library logo"></a>
11+
</header>
12+
<nav>
13+
<ul>
14+
<li>
15+
<a href="/">Home</a>
16+
</li>
17+
<li>
18+
<a href="index.html">README</a>
19+
</li>
20+
<li>
21+
<a href="license.html">LICENSE</a>
22+
</li>
23+
<li>
24+
<a href="install.html">INSTALL</a>
25+
</li>
26+
<li>
27+
<a href="docs/">Documentation</a>
28+
</li>
29+
<li>
30+
<a href="how-to/">How To</a>
31+
</li>
32+
<li>
33+
<a href="about.html">About</a>
34+
</li>
35+
<li>
36+
<a
37+
href="https://github.com/caltechlibrary/datatools">Github</a>
38+
</li>
39+
</ul>
40+
</nav>
41+
42+
<section>
43+
<h1 id="name">
44+
NAME
45+
</h1>
46+
<p>
47+
sql2csv
48+
</p>
49+
<h1 id="synopsis">
50+
SYNOPSIS
51+
</h1>
52+
<p>
53+
sql2csv <a href="#options">OPTIONS</a> SQL_STATEMENT
54+
</p>
55+
<p>
56+
sql2csv <a href="#options">OPTIONS</a> CONFIG_FILE SQL_STATEMENT
57+
</p>
58+
<h1 id="description">
59+
DESCRIPTION
60+
</h1>
61+
<p>
62+
sql2csv takes a config file describing a SQL database connection and
63+
output options needed and a SQL statement as the final parameter. The
64+
output of the SQL query is rendered in CSV format to standard out.
65+
sql2csv supports querying MySQL 8, Postgres and SQLite3 databases.
66+
</p>
67+
<p>
68+
The configuration file is a JSON document with the following key value
69+
pairs.
70+
</p>
71+
<dl>
72+
<dt>
73+
dsn_url
74+
</dt>
75+
<dd>
76+
(string) A data source name in URL form where the “protocol” element
77+
identifies the database resource being accessed (e.g. “sqlite://”,
78+
“mysql://”, “postgres://”). A data source name are rescribed at <a
79+
href="https://github.com/golang/go/wiki/SQLInterface"
80+
class="uri">https://github.com/golang/go/wiki/SQLInterface</a>.
81+
</dd>
82+
<dt>
83+
header_row
84+
</dt>
85+
<dd>
86+
(boolean) if true print a header row in the output, false for no header
87+
row output
88+
</dd>
89+
<dt>
90+
delimiter
91+
</dt>
92+
<dd>
93+
(single character, default is “,”), sets the field delimited used in
94+
output. It can be set to “ for tab separated values.
95+
</dd>
96+
<dt>
97+
use_crlf
98+
</dt>
99+
<dd>
100+
(boolean, default is false) if set to true to use “” as the line
101+
terminator between rows of output.
102+
</dd>
103+
</dl>
104+
<p>
105+
To connect with a database sql2csv relies on a data source name (DSN) in
106+
URL format. In the URL form the URL’s scheme indicates the type of
107+
database you are connecting to (e.g. sqlite, mysql, postgres). The rest
108+
of the DNS has the following form
109+
</p>
110+
<pre><code>[username[:password]@][protocol[(address)]]/dbname[?param1=value1&amp;...&amp;paramN=valueN]</code></pre>
111+
<p>
112+
For a simple database like SQLite3 a minimal DSN in url form for a
113+
database file “my_database.sqlite3” would look like
114+
</p>
115+
<pre><code> sqlite://file:my_database.sqlite3</code></pre>
116+
<p>
117+
For MySQL you need to provide more information to connect
118+
(e.g. username, password). In this example the username is “jane.doe”,
119+
password is “something_secret” the database is “my_database”. (this
120+
example assumes that MySQL 8 is running on localhost at the usual port).
121+
</p>
122+
<pre><code> mysql://jane.doe:something_secret@/my_database</code></pre>
123+
<p>
124+
Postgres is similar to the MySQL connection string except the “scheme”
125+
is “postgres” instead of “mysql”.
126+
</p>
127+
<h1 id="options">
128+
OPTIONS
129+
</h1>
130+
<dl>
131+
<dt>
132+
-help
133+
</dt>
134+
<dd>
135+
display help
136+
</dd>
137+
<dt>
138+
-version
139+
</dt>
140+
<dd>
141+
display version
142+
</dd>
143+
<dt>
144+
-license
145+
</dt>
146+
<dd>
147+
display license
148+
</dd>
149+
</dl>
150+
<p>
151+
A the following options will override a configuration.
152+
</p>
153+
<dl>
154+
<dt>
155+
-dsn
156+
</dt>
157+
<dd>
158+
use the data source name in URL form instead of a JSON configuration
159+
file
160+
</dd>
161+
<dt>
162+
-header
163+
</dt>
164+
<dd>
165+
use a header row if true, false skip the header row
166+
</dd>
167+
<dt>
168+
-delimiter
169+
</dt>
170+
<dd>
171+
Set the delimiter to use, default is comma
172+
</dd>
173+
<dt>
174+
-use-cdlf
175+
</dt>
176+
<dd>
177+
Force the line ending per row to carage return and line feed if true,
178+
false use line feed
179+
</dd>
180+
</dl>
181+
<h1 id="example">
182+
EXAMPLE
183+
</h1>
184+
<p>
185+
Using the “dbcfg.json” configuration file, display ten rows from table
186+
“mytable” in database indicated in “dbcfg.json”.
187+
</p>
188+
<p>
189+
sql2csv dbcfg.json ‘SELECT * FROM mytable LIMIT 10’
190+
</p>
191+
<p>
192+
The CSV output is written standard out and can be redirected into a file
193+
if desired.
194+
</p>
195+
<p>
196+
sql2csv dbcfg.json ‘SELECT * FROM mytable LIMIT 10’<br />
197+
&gt;ten-rows.csv
198+
</p>
199+
<p>
200+
sql2csv 1.1.5
201+
</p>
202+
</section>
203+
204+
<footer>
205+
<span><h1><A href="http://caltech.edu">Caltech</a></h1></span>
206+
<span>&copy; 2021 <a href="https://www.library.caltech.edu/copyright">Caltech library</a></span>
207+
<address>1200 E California Blvd, Mail Code 1-32, Pasadena, CA 91125-3200</address>
208+
<span>Phone: <a href="tel:+1-626-395-3405">(626)395-3405</a></span>
209+
<span><a href="mailto:[email protected]">Email Us</a></span>
210+
<a class="cl-hide" href="sitemap.xml">Site Map</a>
211+
</footer>
212+
</body>
213+
</html>

sql2csv.1.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
% sql2csv (1) user manual
2-
% R. S. Doiel
3-
% 2023-01-03
1+
---
2+
title: "sql2csv (1) user manual"
3+
author: "R. S. Doiel"
4+
pubDate: 2023-01-05
5+
---
46

57
# NAME
68

0 commit comments

Comments
 (0)