annotate docs/source/capabilities.rst @ 444:e89db2eaa0b4

removed refs to sqlalchemy
author catherine@Drou
date Tue, 09 Feb 2010 08:24:30 -0500
parents 2fd766784ff2
children b34ea206c7d1
rev   line source
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
1 ==============================
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
2 SQLPython's extra capabilities
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
3 ==============================
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
4
444
e89db2eaa0b4 removed refs to sqlalchemy
catherine@Drou
parents: 373
diff changeset
5 SQLPython's primary function is to allow entry of SQL queries, much like
e89db2eaa0b4 removed refs to sqlalchemy
catherine@Drou
parents: 373
diff changeset
6 SQL*Plus, psql, and the mysql command-line client. It aims to reproduce
e89db2eaa0b4 removed refs to sqlalchemy
catherine@Drou
parents: 373
diff changeset
7 as many SQL*Plus capabilities as possible. In addition, it offers several
e89db2eaa0b4 removed refs to sqlalchemy
catherine@Drou
parents: 373
diff changeset
8 extra features inspired by other command-line clients.
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
9
279
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
10 Neatened output
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
11 ===============
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
12
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
13 When printing query results, sqlpython economizes on screen space by allocating
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
14 only the width each column actually needs.
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
15
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
16 Smart prompt
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
17 ============
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
18
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
19 sqlpython automatically uses `username`@`instance`> as its prompt, helping
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
20 avoid wrong-instance and wrong-user errors.
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
21
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
22 Tab completion
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
23 ==============
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
24
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
25 When typing SQL commands, hitting `<TAB>` after entering part of an object
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
26 or column name brings up a list of appropriate possibilities or, if there
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
27 is only one possibility, fills in the rest of the name. This feature is
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
28 not yet very reliable, but can save typing.
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
29
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
30 Scripting
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
31 =========
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
32
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
33 Like SQL\*Plus, sqlpython can run scripts (text files with series of SQL and
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
34 sqlpython commands) with `@/path/to/script.sql` or (for online scripts)
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
35 `@http://scripthost/scriptlibrary/script.sql`.
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
36
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
37 History
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
38 =======
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
39
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
40 The up- and down-arrow keys allow you to scroll through the lines entered so far
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
41 in your sqlpython session.
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
42
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
43 Commands are also entered into a command history.
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
44
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
45 history *or* hi
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
46 List entire command history
279
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
47
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
48 list *or* li
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
49 List only last command
279
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
50
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
51 hi `<N>`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
52 List command number <N> from history.
279
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
53
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
54 hi `<N>-`, hi `-<N>`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
55 List commands from <N> onward, or up to <N>
279
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
56
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
57 hi `<str>`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
58 Lists commands that include the string <str>
279
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
59
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
60 hi `/<regex>/`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
61 Lists commands that match the regular expression <regex>
279
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
62
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
63 run, r, *or* `\\g`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
64 Run the most recent command again
279
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
65
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
66 run `<N>`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
67 Run command <N>
279
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
68
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
69 run `<str>`, run `/<regex>/`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
70 Run command matching <str> or <regex> (as for `history`) -
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
71 if multiple items would match, run most recent
279
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
72
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
73 Special I/O destinations
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
74 ========================
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
75
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
76 Much as in a UNIX shell, you can follow a command with a special output destination.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
77
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
78 `> {filename}` sends the output to a file. This is more convenient than SQL\*Plus's
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
79 SPOOL {filename}... SPOOL OFF (though you can use those as well).
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
80
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
81 `>` alone (no filename) sends the output to the paste buffer.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
82
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
83 `|` pipes the output to an operating-system command.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
84
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
85 When `< {filename}` is included in your command, it is replaced with the contents of
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
86 {filename} before the command is run.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
87
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
88 Examples::
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
89
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
90 Need examples!!!!
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
91
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
92 Special output formats
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
93 ======================
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
94
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
95 By replacing the `;` that terminates a SELECT statement with a backslash-character
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
96 sequence, you can get output in a number of useful formats. The `terminators`
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
97 command lists them, for your convenience.
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
98
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
99 ========== ======================== ================================
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
100 terminator format Useful for
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
101 ========== ======================== ================================
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
102 ; standard Oracle format
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
103 \\c CSV (with headings) sending to spreadsheets
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
104 \\C CSV (no headings)
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
105 \\g list wide output with linewraps
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
106 \\G aligned list
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
107 \\h HTML table web reports
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
108 \\i INSERT statements copying to other instances
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
109 \\j JSON
329
3efffbf7481f fixed bug in assigning 0, null to bind vars
Catherine Devlin <catherine.devlin@gmail.com>
parents: 294
diff changeset
110 \\r ReStructured Text inclusion in documentation
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
111 \\s CSV (with headings)
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
112 \\S CSV (no headings)
329
3efffbf7481f fixed bug in assigning 0, null to bind vars
Catherine Devlin <catherine.devlin@gmail.com>
parents: 294
diff changeset
113 \\t transposed "wide" tables like v$database
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
114 \\x XML
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
115 \\l line plot, with markers
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
116 \\L scatter plot (no lines)
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
117 \\b bar graph
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
118 \\p pie chart
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
119 ========== ======================== ================================
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
120
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
121 Most of these output formats are even more useful when combined with special output
329
3efffbf7481f fixed bug in assigning 0, null to bind vars
Catherine Devlin <catherine.devlin@gmail.com>
parents: 294
diff changeset
122 destinations. For example, `SELECT * FROM party\\h > /var/www/party_report.html`
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
123 could create an HTML report in the webserver's documents directory, ready to serve.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
124
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
125 UNIX-like commands
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
126 ==================
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
127
279
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
128 Many sqlpython commands allow you to act as though the database objects
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
129 were files in a UNIX filesystem. Many of the commands also accept flags
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
130 to modify their behavior.
3c5fa8ed4f8b improving help
catherine@Elli.myhome.westell.com
parents: 247
diff changeset
131
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
132 ls `{object type/object name, with wildcards}`
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
133 Lists objects from the data dictionaries, as though they were in a
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
134 *object_type*/*object_name* directory structure. Thus, `ls view/\*`
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
135 lists all the user's views. Calling with no argument is equivalent
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
136 to `ls *`.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
137
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
138 Options::
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
139
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
140 -l, --long long descriptions
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
141 -a, --all all schemas' objects (otherwise, you only get your own)
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
142 -t, --timesort Sort by last_ddl_time
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
143 -r, --reverse Reverse order while sorting
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
144
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
145 `ls -lt *;10` lists the ten items with the most recent last_ddl_time;
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
146 this can be a good way to answer the question, "What was I working on?"
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
147
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
148 cat `{remainder of query}`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
149 Shorthand for "SELECT * FROM". Can be combined with anything else
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
150 that fits into a SELECT statement (WHERE, ORDER BY, etc.)
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
151
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
152 grep `{target}` `{table}` `[{table2,...}]`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
153 Equivalent to SELECT * FROM {table} WHERE *any column* LIKE '%{target}%'.
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
154 Useful when you don't know, don't remember, or don't care which column
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
155 a value may be found in.
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
156
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
157 Options::
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
158
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
159 -i, --ignore-case Case-insensitive search
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
160
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
161 find -c {target}, find -t {column}
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
162 Lists all tables or columns whose names contain {target}. More convenient than
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
163 querying user_tab_columns/all_tab_columns or user_tables/all_tables.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
164 Options::
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
165
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
166 -a Find all objects (not just my own)
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
167
286
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
168 Data dictionary exploration
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
169 ===========================
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
170
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
171 refs `{table_name}`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
172 Lists all foreign key constraints on the table or referring to the table.
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
173
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
174 deps `{object_name}`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
175 Lists all objects dependent upon the named object.
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
176
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
177 comments `{table_name}`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
178 Prints comments on a table and its columns.
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
179
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
180 PL/SQL source code
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
181 ==================
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
182
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
183 pull {object_name}
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
184 Displays the PL/SQL source code for {object_name}.
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
185
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
186 Options:
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
187 -d, --dump dump results to files (object_type/object_name.sql)
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
188 -f, --full get dependent objects as well
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
189 -a, --all all schemas' objects
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
190
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
191 bzr, git, hg `{object_name}`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
192 Dump source code to files, as `pull -f`, but also creates or commits to a
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
193 repository of the appropriate distributed version control system
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
194 (Bazaar, Git, or Mercurial, respectively).
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
195
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
196 find `{target}`
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
197 Lists all PL/SQL objects whose source code contains the {target} string.
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
198 Always case-insensitive.
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
199 Options::
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
200
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
201 -a Search all PL/SQL objects (not just my own)
abb4c6524113 adding ioug paper
catherine@dellzilla
parents: 283
diff changeset
202
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
203 PostgreSQL-like shortcuts
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
204 =========================
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
205
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
206 psql, the command-line client for the open-source database `PostgreSQL <http://www.postgresql.org/>`_ uses a number
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
207 of backslash-character sequences as convenient shortcuts. sqlpython steals many of
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
208 them.
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
209
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
210 ===== ===================
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
211 \\c connect
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
212 \\d desc
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
213 \\e edit
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
214 \\g run
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
215 \\h help
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
216 \\i load
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
217 \\o spool
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
218 \\p list
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
219 \\q quit
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
220 \\w save
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
221 \\db _dir_tablespaces
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
222 \\dd comments
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
223 \\dn _dir_schemas
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
224 \\dt _dir_tables
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
225 \\dv _dir_views
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
226 \\di _dir_indexes
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
227 \\? help psql
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
228 ===== ===================
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
229
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
230 Bind variables
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
231 ==============
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
232
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
233 Bind variables work in sqlpython as they do in SQL\*Plus, but they are set dynamically; there
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
234 is no need to declare them before use. The syntax for setting them is more permissive than
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
235 in SQL\*Plus; all these are recognized::
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
236
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
237 exec :mybind := 'value'
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
238 exec :mybind = 'value'
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
239 :mybind := 'value'
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
240 :mybind = 'value'
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
241
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
242 The current values of all bind variables can be viewed with the `print` command.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
243
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
244 The `bind` command creates and populates bind variables for the final row of the most recent
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
245 SELECT statement executed; each column name is used as a bind variable, which is filled with
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
246 the value. `bind -r {rownumber}` does the same, but fills from row {rownumber} instead of
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
247 from the final row (row numbers begin at 0 for this command).
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
248
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
249 When the `autobind` sqlpython parameter is True, a `bind` statement is issued automatically
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
250 after every query that returns exactly one row.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
251
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
252 Bind variables are available from within Python as a dictionary named `binds` (see Python).
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
253
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
254 Substitution variables
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
255 ======================
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
256
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
257 Substitution variables ("&" variables) work much as they do in SQL\*Plus. As in SQL\*Plus,
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
258 the `scan` parameter determines whether queries are scanned to replace substitution
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
259 variables. Unlike SQL\*Plus, sqlpython knows how annoying it is to hit a substitution
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
260 variable you didn't expect, so entering "SET SCAN OFF" when prompted for a substitution
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
261 variable actually aborts the substitution process.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
262
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
263 Wild SQL
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
264 ========
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
265
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
266 Wild SQL is a nonstandard SQL feature that must be enabled with `set wildsql on`. When it is
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
267 enabled, column names in a SELECT statement do not need to be explicitly typed; they can be
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
268 specified with special Wild SQL symbols: wildcards (`*`, `%`, `_`); column numbers (`#{N}`);
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
269 and NOT-style exclusion (`!`). The symbols can even be combined.
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
270
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
271 ::
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
272
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
273 jrrt@orcl> cat party
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
274
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
275 NAME STR INT WIS DEX CON CHA
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
276 ------- --- --- --- --- --- ---
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
277 Frodo 8 14 16 15 14 16
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
278 Gimli 17 12 10 11 17 11
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
279 Legolas 13 15 14 18 15 17
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
280 Sam 11 9 14 11 16 13
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
281
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
282 4 rows selected.
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
283
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
284 jrrt@orcl> set wild on
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
285 wildsql - was: False
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
286 now: True
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
287 jrrt@orcl> select *i* from party;
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
288
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
289 INT WIS
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
290 --- ---
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
291 14 16
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
292 12 10
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
293 15 14
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
294 9 14
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
295
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
296 4 rows selected.
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
297
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
298 jrrt@orcl> select #1, #5 from party;
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
299
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
300 NAME DEX
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
301 ------- ---
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
302 Frodo 15
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
303 Gimli 11
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
304 Legolas 18
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
305 Sam 11
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
306
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
307 4 rows selected.
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
308
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
309 jrrt@orcl> select !str from party;
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
310
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
311 NAME INT WIS DEX CON CHA
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
312 ------- --- --- --- --- ---
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
313 Frodo 14 16 15 14 16
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
314 Gimli 12 10 11 17 11
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
315 Legolas 15 14 18 15 17
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
316 Sam 9 14 11 16 13
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
317
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
318 4 rows selected.
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
319
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
320 jrrt@orcl> select n*, !#3, !c* from party;
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
321
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
322 NAME STR WIS DEX
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
323 ------- --- --- ---
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
324 Frodo 8 16 15
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
325 Gimli 17 10 11
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
326 Legolas 13 14 18
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
327 Sam 11 14 11
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
328
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
329 4 rows selected.
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
330
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
331 Wild SQL symbols only work in the first SELECT statement in a query; they do not work in
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
332 subqueries, subsequent UNIONed queries, etc.
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
333
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
334 Python
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
335 ======
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
336
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
337 The `py` command allows the user to execute Python commands, either one-at-a-time (with
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
338 `py {command}`) or in an interactive environment (beginning with a bare `py` statement,
294
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
339 and continuing until Ctrl-D, `quit()`, or `exit()` is entered).
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
340
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
341 A history of result sets from each query is exposed to the python session as the list `r`;
294
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
342 the most recent result set is `r[-1]`. Each row can be references as a tuple, or as an
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
343 object with an attribute for each column.
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
344
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
345 Bind variables are exposed as the dictionary `binds`. Each row from each result set has
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
346 a .bind() method that fills a bind varible for each column with that row's value.
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
347
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
348 Resultsets in `r` are read-only, but `binds` can be written as well as read, and will
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
349 be working bind variables in the SQL environment.
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
350
294
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
351 SQL and sqlpython commands can be issued from the Python environment with `sql("{your SQL}")`.
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
352
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
353 All variables are retained each time the python environment is entered (whether interactively,
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
354 or with one-line `py` statements).
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
355 ::
247
f0f293d83337 begin docs
catherine@dellzilla
parents:
diff changeset
356
294
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
357 0:testschema@orcl> select title, author from play;
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
358
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
359 TITLE AUTHOR
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
360 --------------- -----------
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
361 Timon of Athens Shakespeare
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
362 Twelfth Night Shakespeare
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
363 The Tempest Shakespeare
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
364 Agamemnon Aeschylus
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
365
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
366 4 rows selected.
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
367
294
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
368 0:testschema@orcl> py import urllib
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
369 0:testschema@orcl> py current_season = urllib.urlopen('http://cincyshakes.com/').read()
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
370 0:testschema@orcl> py
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
371 Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
372 [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
373 Type "help", "copyright", "credits" or "license" for more information.
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
374 (mysqlpy)
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
375
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
376 py <command>: Executes a Python command.
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
377 py: Enters interactive Python mode; end with `Ctrl-D`, `quit()`, or 'exit`.
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
378 Past SELECT results are exposed as list `r`;
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
379 most recent resultset is `r[-1]`.
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
380 SQL bind, substitution variables are exposed as `binds`, `substs`.
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
381 SQL and sqlpython commands can be issued with sql("your non-python command here").
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
382
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
383 >>> r[-1]
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
384 [('Timon of Athens', 'Shakespeare'), ('Twelfth Night', 'Shakespeare'), ('The Tempest', 'Shakespeare'), ('Agamemnon', 'Aeschylus')]
294
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
385 >>> r[-1][0][0]
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
386 'Timon of Athens'
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
387 >>> for row in r[-1]:
294
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
388 ... print "%s, by %s" % (row.title, row.author)
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
389 ...
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
390 Timon of Athens, by Shakespeare
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
391 Twelfth Night, by Shakespeare
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
392 The Tempest, by Shakespeare
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
393 Agamemnon, by Aeschylus
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
394 >>> [row.title for row in r[-1] if row.title in current_season]
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
395 ['Timon of Athens', 'Twelfth Night']
294
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
396 >>> binds['author'] = 'Shakespeare'
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
397 >>> query = "SELECT title FROM play WHERE author = :author"
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
398 >>> sql(query)
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
399
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
400 TITLE
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
401 ---------------
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
402 Timon of Athens
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
403 Twelfth Night
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
404 The Tempest
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
405
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
406 3 rows selected.
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
407
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
408 >>> r[-1]
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
409 [('Timon of Athens',), ('Twelfth Night',), ('The Tempest',)]
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
410 >>> r[-1][0]
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
411 ('Timon of Athens',)
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
412 >>> r[-1][0].bind()
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
413 >>> binds['title']
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
414 'Timon of Athens'
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
415 >>> quit()
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
416 0:testschema@orcl> select title, author from play where title = :title;
282
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
417
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
418 TITLE AUTHOR
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
419 --------------- -----------
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
420 Timon of Athens Shakespeare
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
421
4eef08cfaf25 copied documentation from blog
catherine@dellzilla
parents: 281
diff changeset
422 1 row selected.
294
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
423
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
424 Parameters
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
425 ==========
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
426
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
427 Several parameters control the behavior of sqlpython itself.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
428
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
429 ===================== =================================================== ===============
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
430 parameter effect default
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
431 ===================== =================================================== ===============
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
432 autobind When True, single-row queries automatically `bind` False
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
433 commit_on_exit Automatically commits work at end of session True
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
434 continuation_prompt Prompt for second line and onward of long statement >
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
435 default_file_name The file opened by `edit`, if not specified afiedt.buf
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
436 echo Echo command entered before executing False
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
437 editor Text editor invoked by `edit`. varies
294
dd7b3e4b58dd new py docs
catherine@dellzilla
parents: 286
diff changeset
438 heading Print column names along with results True
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
439 maxfetch Maximum number of rows to return from any query 1000
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
440 maxtselctrows Maximum # of rows from a tselect or \\n query 10
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
441 prompt Probably unwise to change user@instance>
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
442 scan Interpret & as indicating substitution variables True
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
443 serveroutput Print DBMS_OUTPUT.PUT_LINE results True
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
444 sql_echo Print text of "behind-the-scenes" queries False
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
445 timeout In seconds 30
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
446 timing Print time for each command to execute False
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
447 wildsql Accept *, %, #, and ! in column names False
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
448 ===================== =================================================== ===============
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
449
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
450 The user can change these with the `set {paramname} {new-value}` statement.
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
451 The True/False parameters accept new values permissively, recognizing "True", "False",
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
452 "T", "F", "yes", "no", "on", "off", etc.
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
453
283
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
454 `set` and `show` both list the current values of the sqlpython parameters. They
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
455 also recognize any abbreviated parameter name, so long as it is long enough to be
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
456 unique. That is, `show maxf` is recognized as `show maxfetch`, but `show max` is
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
457 too short to distinguish between `maxfetch` and `maxtselctrows`.
80484bc60bdd still needs refs
catherine@dellzilla
parents: 282
diff changeset
458
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
459 `show parameter {param}` shows current Oracle parameters (from v$parameter), as it does
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
460 in SQL\*Plus.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
461
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
462 Tuning
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
463 ======
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
464
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
465 In sqlpython, `explain {SQL ID}` shows the execution plan for the SQL statement with the
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
466 given ID. If SQL ID is omitted, it defaults to the most recent SQL executed.
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
467 (This is not necessarily the last statement `EXPLAIN PLAN` was issued against.)
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
468
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
469 Other specialized sqlpython tuning commands include:
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
470
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
471 load
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
472 Displays OS load on cluster nodes (10gRAC)
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
473
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
474 longops
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
475 Displays long-running operations
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
476
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
477 sessinfo
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
478 Reports session info for the given sid, extended to RAC with gv$
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
479
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
480 top, top9i
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
481 Displays active sessions
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
482
373
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
483 BLOB display
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
484 ============
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
485
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
486 (Oracle only, for now)
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
487
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
488 When a SELECT query returns BLOB columns, most SQL tools simply cannot
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
489 display the results. Sqlpython, however, will create
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
490 a local file for each BLOB returned (up to the parameter `bloblimit`),
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
491 and return the filepaths of the new files in the query results. In a
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
492 tool like the GNOME terminal, these filepaths work as right-clickable
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
493 links that can open the files.
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
494
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
495 When the \\h terminator is used to generate HTML table output, if the
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
496 BLOBs are images, they will be embedded as images in the generated
2fd766784ff2 semi-automate documentation upload
catherine@DellZilla
parents: 329
diff changeset
497 table.
281
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
498
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
499
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
500
701f0aae837a got maxtselctrows working again
catherine@dellzilla
parents: 280
diff changeset
501