@@ -23,22 +23,32 @@ executed. Statements are executed using one of these methods
2323This chapter discusses python-oracledb's synchronous methods. The asynchronous
2424methods and pipelining functionality are discussed in detail in :ref: `asyncio `.
2525
26- PL/SQL statements are discussed in :ref: `plsqlexecution `. Other chapters
27- contain information on specific data types and features. See :ref: `batchstmnt `,
28- :ref: `lobdata `, :ref: `jsondatatype `, and :ref: `xmldatatype `.
26+ PL/SQL statements are discussed in :ref: `plsqlexecution `. The following
27+ chapters contain information on specific data types and features:
28+
29+ - :ref: `batchstmnt `
30+ - :ref: `pipelining `
31+ - :ref: `lobdata `
32+ - :ref: `jsondatatype `
33+ - :ref: `xmldatatype `
34+
35+ **Executing SQL Scripts **
2936
3037Python-oracledb can be used to execute individual statements, one at a time.
3138Once a statement has finished execution, only then will the next statement
3239execute. If you try to execute statements concurrently in a single connection,
3340the statements are queued and run consecutively in the order they are executed
34- in the application code.
41+ in the application code. This includes :ref: `Pipelined statements
42+ <pipelining>`.
3543
3644Python-oracledb does not read SQL*Plus ".sql" files. To read SQL files, use a
3745technique like the one in ``run_sql_script() `` in `samples/sample_env.py
3846<https://github.com/oracle/python-oracledb/blob/main/samples/sample_env.py> `__.
3947
40- SQL statements should not contain a trailing semicolon (";") or forward slash
41- ("/"). This will fail:
48+ **SQL Statement Syntax **
49+
50+ SQL statements executed in python-oracledb should not contain a trailing
51+ semicolon (";") or forward slash ("/"). This will fail:
4252
4353.. code-block :: python
4454
@@ -50,17 +60,6 @@ This is correct:
5060
5161 cursor.execute(" select * from MyTable" )
5262
53-
54- SQL Queries
55- ===========
56-
57- Queries (statements beginning with SELECT or WITH) can be executed using the
58- method :meth: `Cursor.execute() `. Rows can then be iterated over, or can be
59- fetched using one of the methods :meth: `Cursor.fetchone() `,
60- :meth: `Cursor.fetchmany() ` or :meth: `Cursor.fetchall() `. There is a
61- :ref: `default type mapping <defaultfetchtypes >` to Python types that can be
62- optionally :ref: `overridden <outputtypehandlers >`.
63-
6463 .. IMPORTANT ::
6564
6665 Interpolating or concatenating user data with SQL statements, for example
@@ -69,6 +68,18 @@ optionally :ref:`overridden <outputtypehandlers>`.
6968 instead, for example ``cursor.execute("SELECT * FROM mytab WHERE mycol =
7069 :mybv", mybv=myvar) ``.
7170
71+
72+ SQL Queries
73+ ===========
74+
75+ Queries (statements beginning with SELECT or WITH) can be executed using the
76+ method :meth: `Cursor.execute() `. Rows can then be iterated over, or can be
77+ fetched using one of the methods :meth: `Cursor.fetchone() `,
78+ :meth: `Cursor.fetchmany() ` or :meth: `Cursor.fetchall() `. This lets you handle
79+ rows directly or stream them if needed. There is a :ref: `default type mapping
80+ <defaultfetchtypes>` to Python types that can be optionally :ref: `overridden
81+ <outputtypehandlers>`.
82+
7283.. _fetching :
7384
7485Fetch Methods
@@ -98,9 +109,10 @@ Rows can be fetched in various ways.
98109 break
99110 print (row)
100111
101- - If rows need to be processed in batches, the method :meth: `Cursor.fetchmany() `
102- can be used. The size of the batch is controlled by the ``size `` parameter,
103- which defaults to the value of :attr: `Cursor.arraysize `.
112+ - If rows need to be streamed or processed in batches, the method
113+ :meth: `Cursor.fetchmany() ` can be used. The size of the batch is controlled
114+ by the ``size `` parameter, which defaults to the value of
115+ :attr: `Cursor.arraysize `.
104116
105117 .. code-block :: python
106118
@@ -116,8 +128,9 @@ Rows can be fetched in various ways.
116128
117129 Note the ``size `` parameter only affects the number of rows returned to the
118130 application, not to the internal buffer size used for tuning fetch
119- performance. That internal buffer size is controlled only by changing
120- :attr: `Cursor.arraysize `, see :ref: `tuningfetch `.
131+ performance. That internal buffer size is controlled only by changing
132+ :attr: `Cursor.arraysize ` or :attr: `oracledb.defaults.arraysize
133+ <Defaults.arraysize> `, see :ref: `tuningfetch `.
121134
122135- If all of the rows need to be fetched and can be contained in memory, the
123136 method :meth: `Cursor.fetchall() ` can be used.
0 commit comments