|
57 | 57 | "Install with a command like one of the following:\n", |
58 | 58 | "\n", |
59 | 59 | "```\n", |
60 | | - "$ python3 -m pip install oracledb --upgrade\n", |
61 | | - "$ python3 -m pip install oracledb --upgrade --user\n", |
62 | | - "$ python3 -m pip install oracledb --upgrade --user --proxy=http://proxy.example.com:80\n", |
| 60 | + "$ python -m pip install oracledb --upgrade\n", |
| 61 | + "$ python -m pip install oracledb --upgrade --user\n", |
| 62 | + "$ python -m pip install oracledb --upgrade --user --proxy=http://proxy.example.com:80\n", |
63 | 63 | "```" |
64 | 64 | ] |
65 | 65 | }, |
|
105 | 105 | "cell_type": "markdown", |
106 | 106 | "metadata": {}, |
107 | 107 | "source": [ |
108 | | - "Instead of hard coding the password, you could prompt for a value, pass it as an environment variable, or use Oracle \"external authentication\"." |
| 108 | + "Instead of hard coding the password in your applications, you could prompt for a value, pass it as an environment variable, or use Oracle \"external authentication\"." |
109 | 109 | ] |
110 | 110 | }, |
111 | 111 | { |
|
133 | 133 | "cell_type": "markdown", |
134 | 134 | "metadata": {}, |
135 | 135 | "source": [ |
136 | | - "Oracle Client 19c improved [Easy Connect Plus](https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-8C85D289-6AF3-41BC-848B-BF39D32648BA) syntax with additional optional settings, for example:\n", |
| 136 | + "Oracle's [Easy Connect](https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-8C85D289-6AF3-41BC-848B-BF39D32648BA) syntax allows many optional settings, for example:\n", |
137 | 137 | "\n", |
138 | 138 | "```\n", |
139 | 139 | "cs = \"tcps://my.cloud.com:1522/orclpdb1?connect_timeout=4&expire_time=10\"\n", |
140 | 140 | "```\n", |
141 | 141 | "\n", |
142 | | - "<!-- See the [technical brief](https://download.oracle.com/ocomdocs/global/Oracle-Net-19c-Easy-Connect-Plus.pdf). -->" |
| 142 | + "See the Oracle Database Easy Connect [technical brief](https://download.oracle.com/ocomdocs/global/Oracle-Net-Easy-Connect-Plus.pdf) for other options." |
143 | 143 | ] |
144 | 144 | }, |
145 | 145 | { |
|
148 | 148 | "source": [ |
149 | 149 | "### Oracle Network and Oracle Client Configuration Files\n", |
150 | 150 | "\n", |
151 | | - "Oracle Database's `tnsnames.ora` file can be used. This file maps a connect descriptor to an alias. \n", |
| 151 | + "Instead of the Easy Connect syntax, a TNS Alias from a `tnsnames.ora` file can be used. This file maps connect descriptors to TNS aliases. \n", |
152 | 152 | "\n", |
153 | 153 | "Documentation reference link: [Optional configuration files](https://python-oracledb.readthedocs.io/en/latest/user_guide/initialization.html#optional-oracle-net-configuration-files)" |
154 | 154 | ] |
|
159 | 159 | "source": [ |
160 | 160 | "\n", |
161 | 161 | "# tnsnames.ora in /opt/oracle/configdir\n", |
162 | | - " \n", |
| 162 | + "\n", |
163 | 163 | "highperfdb = (description= \n", |
164 | 164 | " (retry_count=5)(retry_delay=3)\n", |
165 | 165 | " (address=(protocol=tcps)(port=1522)(host=xxxxxx.oraclecloud.com))\n", |
|
173 | 173 | "cell_type": "markdown", |
174 | 174 | "metadata": {}, |
175 | 175 | "source": [ |
176 | | - "Your Python code could use the alias as the connection `dsn` value:\n", |
| 176 | + "Your Python code could use the TNS Alias as the connection `dsn` value:\n", |
177 | 177 | "```\n", |
178 | 178 | "connection = oracledb.connect(user=un, password=pw, dsn=\"highperfdb\", config_dir=\"/opt/oracle/configdir\")\n", |
179 | 179 | "```" |
|
192 | 192 | "source": [ |
193 | 193 | "### Standalone Connections\n", |
194 | 194 | "\n", |
195 | | - "Standalone connections are simple to create." |
| 195 | + "Standalone connections are simple to create. They are suitable for single-user applications that do not run very long." |
196 | 196 | ] |
197 | 197 | }, |
198 | 198 | { |
|
208 | 208 | "metadata": {}, |
209 | 209 | "outputs": [], |
210 | 210 | "source": [ |
211 | | - "# Stand-alone Connections\n", |
| 211 | + "# Stand-alone Connection\n", |
212 | 212 | "\n", |
213 | 213 | "connection = oracledb.connect(user=un, password=pw, dsn=cs)\n", |
214 | 214 | "\n", |
|
227 | 227 | "metadata": {}, |
228 | 228 | "source": [ |
229 | 229 | "#### Pools are highly recommended if you have:\n", |
230 | | - "- a lot of connections that will be used for short periods of time\n", |
231 | | - "- or a small number of connections that are idle for long periods of time\n", |
| 230 | + "- A lot of connections that will be used for short periods of time\n", |
| 231 | + "- Or a small number of connections that are idle for long periods of time\n", |
232 | 232 | "\n", |
233 | 233 | "#### Pool advantages\n", |
| 234 | + "Try to architect your applications to use connection pools to take advantage of:\n", |
| 235 | + "\n", |
234 | 236 | "- Reduced cost of setting up and tearing down connections\n", |
235 | 237 | "- Dead connection detection and automatic re-establishment" |
236 | 238 | ] |
|
278 | 280 | "cell_type": "markdown", |
279 | 281 | "metadata": {}, |
280 | 282 | "source": [ |
281 | | - "Close connections when not needed. This is important for pooled connections.\n", |
| 283 | + "Close connections when not needed. This is important for pooled connections. With a connection pool, closing the connection releases it back to the pool for later reuse.\n", |
| 284 | + "\n", |
| 285 | + "To avoid resource closing order issues, you should use `with` or let resources be closed at end of scope:\n", |
282 | 286 | "\n", |
283 | 287 | "```\n", |
284 | | - "connection.close()\n", |
| 288 | + "with pool.acquire() as connection:\n", |
| 289 | + " do_something(connection)\n", |
285 | 290 | "```\n", |
286 | 291 | "\n", |
287 | | - "To avoid resource closing order issues, you may want to use `with` or let resources be closed at end of scope:\n", |
| 292 | + "Or you can explicitly close connections:\n", |
288 | 293 | "\n", |
289 | 294 | "```\n", |
290 | | - "with pool.acquire() as connection:\n", |
291 | | - " do_something(connection)\n", |
| 295 | + "connection.close()\n", |
292 | 296 | "```" |
293 | 297 | ] |
294 | 298 | }, |
|
333 | 337 | "cell_type": "markdown", |
334 | 338 | "metadata": {}, |
335 | 339 | "source": [ |
336 | | - "#### Memory example with 5000 application users and a DRCP pool of size 100\n", |
337 | | - "" |
| 340 | + "#### Database memory usage example with 5000 application users and a DRCP pool of size 100\n", |
| 341 | + "\n", |
| 342 | + "The numbers are examples." |
338 | 343 | ] |
339 | 344 | }, |
340 | 345 | { |
|
375 | 380 | "name": "python", |
376 | 381 | "nbconvert_exporter": "python", |
377 | 382 | "pygments_lexer": "ipython3", |
378 | | - "version": "3.9.6" |
| 383 | + "version": "3.9.24" |
379 | 384 | } |
380 | 385 | }, |
381 | 386 | "nbformat": 4, |
|
0 commit comments