Skip to content

Commit 4a8ab01

Browse files
Update README.org
1 parent 77fb389 commit 4a8ab01

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

README.org

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,54 @@
11
* format-table
22
Emacs can access many RDBMS systems via their command-line utilities using SQLi/comint, however each utility has its own output format for tables and affected row counts. This library allows for conversion between the output formats of many common RDBMS systems, as well as org tables and json.
3+
4+
** Usage
5+
6+
#+BEGIN_SRC emacs-lisp
7+
(format-table string-containing-table input-mode-to-match-string desired-output-mode)
8+
#+END_SRC
9+
10+
For instance, to reformat an org-mode table, do the following:
11+
#+BEGIN_SRC emacs-lisp
12+
(let ((to-format
13+
"| Foo | Bar |
14+
|-----+-----|
15+
| 1 | 2 |
16+
| 3 | 4 |"))
17+
(format-table to-format 'org 'mysql))
18+
#+END_SRC
19+
20+
Which will render the following output:
21+
#+BEGIN_SRC
22+
+-----+-----+
23+
| Foo | Bar |
24+
+-----+-----+
25+
| 1 | 2 |
26+
| 3 | 4 |
27+
+-----+-----+
28+
2 rows in set (0.00 sec)
29+
#+END_SRC
30+
31+
** Supported Formats
32+
33+
The following input/output formats are currently supported:
34+
- ms
35+
- org
36+
- mysql
37+
- postgresql
38+
- json
39+
40+
New formats can be added by adding them to `format-table-format-alist' at runtime.
41+
42+
*** JSON note
43+
44+
Currently only exporting/importing arrays of hashes is supported. For instance, that previous org table:
45+
46+
| Foo | Bar |
47+
|-----+-----|
48+
| 1 | 2 |
49+
| 3 | 4 |
50+
51+
Will render as:
52+
#+BEGIN_SRC javascript
53+
[{"Foo":"1","Bar":"2"},{"Foo":3,"Bar":"4"}]
54+
#+END_SRC

0 commit comments

Comments
 (0)