Mercurial > sqlpython
comparison README.txt @ 103:4aa28dffe658 1.4.6
command-line args working well
author | catherine@localhost |
---|---|
date | Thu, 29 May 2008 14:20:55 -0400 |
parents | 51e1fe3adf0e |
children |
comparison
equal
deleted
inserted
replaced
102:c5f601abc993 | 103:4aa28dffe658 |
---|---|
28 Use sqlpython more or less as you would use SQL\*Plus. | 28 Use sqlpython more or less as you would use SQL\*Plus. |
29 | 29 |
30 Read the help. Experiment with UNIX-style and postgresql-style | 30 Read the help. Experiment with UNIX-style and postgresql-style |
31 commands. | 31 commands. |
32 | 32 |
33 Special output (inspired by YASQL) | |
34 ---------------------------------- | |
35 | |
36 An integer following a command terminator limits output to that number of rows, like SQL's LIMIT keyword:: | |
37 | |
38 hr@xe> SELECT * FROM jobs;2 | |
39 | |
40 If `;` is replaced by one of these special characters, the output will be formatted as such:: | |
41 | |
42 ---------- ---------------------- | |
43 terminator format | |
44 ---------- ---------------------- | |
45 ; standard Oracle format | |
46 \c CSV (with headings) | |
47 \C CSV (no headings) | |
48 \g list | |
49 \G aligned list | |
50 \h HTML table | |
51 \i INSERT statements | |
52 \s CSV (with headings) | |
53 \S CSV (no headings) | |
54 \t transposed | |
55 \x XML | |
56 ---------- ---------------------- | |
57 | |
58 Special terminators can also be combined with row limits:: | |
59 | |
60 hr@xe> SELECT * FROM jobs\h5 | |
61 | |
62 Redirecting output | |
63 ------------------ | |
64 | |
65 `>` and `>>` write or append the output of a command. If a | |
66 filename is given, that will be the destination of the output. | |
67 | |
68 If no filename is given, the output will go into the paste buffer and | |
69 can immediately pasted to any program. This requires `xclip` (*nix) or | |
70 `pywin32` (Windows) to be installed on the operating system. | |
71 | |
72 Connecting | |
73 ---------- | |
74 | |
75 sqlpython supports every version of connecting that SQL*Plus does, including EZCONNECT:: | |
76 | |
77 $ > sqlpython | |
78 $ > sqlpython hr/hr@xe | |
79 $ > sqlpython hr (uses ORACLE_SID, prompts for password) | |
80 $ > sqlpython hr/hr@hostmachine.somewhere.com/xe | |
81 $ > sqlpython hr/hr@hostmachine.somewhere.com:1521/xe | |
82 $ > sqlpython sys@xe as sysdba | |
83 | |
84 You may also supply commands that will be run immediately after connection:: | |
85 | |
86 $ > sqlpython hr/hr@xe @myscript.sql @another_script.sql quit | |
87 | |
88 Multi-word commands must be enclosed in double-quotes:: | |
89 | |
90 $ > sqlpython hr/hr@xe "cat jobs" "select * from employees;" | |
91 | |
92 Combining special output terminators with redirectors and command-line arguments | |
93 can produce powerful one-line programs. For instance, this generates an HTML | |
94 report and exits:: | |
95 | |
96 $ > sqlpython hr/hr@xe "select * from jobs\h > jobs.html" quit | |
97 | |
33 Modifying | 98 Modifying |
34 --------- | 99 --------- |
35 | 100 |
36 Modify mysqlpy.py; add `do_mycommand(self, arg)` | 101 Modify mysqlpy.py; add `do_mycommand(self, arg)` |
37 methods to the mysqlpy class to add your own commands. | 102 methods to the mysqlpy class to add your own commands. |