@@ -31,13 +31,15 @@ To install YDB Python SDK through Pypi execute the following command::
3131Usage
3232-----
3333
34- Import ydb package:
34+ Import Package
35+ ^^^^^^^^^^^^^^
3536
3637.. code-block :: python
3738
3839 import ydb
3940
40- Driver initialization:
41+ Driver Initialization
42+ ^^^^^^^^^^^^^^^^^^^^^
4143
4244.. code-block :: python
4345
@@ -51,6 +53,65 @@ Driver initialization:
5153 ) as driver:
5254 driver.wait(timeout = 5 , fail_fast = True )
5355
56+ SessionPool Initialization
57+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
59+ .. code-block :: python
60+
61+ with ydb.QuerySessionPool(driver) as pool:
62+ pass
63+
64+ Query Execution
65+ ^^^^^^^^^^^^^^^
66+
67+ Python SDK supports queries described by YQL syntax.
68+ There are two primary methods for executing queries, each with different properties and use cases:
69+
70+ * ``pool.execute_with_retries ``:
71+ * Buffers the entire result set in client memory.
72+ * Automatically retries execution in case of retriable issues.
73+ * Does not allow specifying a transaction execution mode.
74+ * Recommended for one-off queries that are expected to produce small result sets.
75+
76+ * ``tx.execute ``:
77+ * Returns an iterator over the query results, allowing processing of results that may not fit into client memory.
78+ * Retries must be handled manually via `pool.retry_operation_sync `.
79+ * Allows specifying a transaction execution mode.
80+ * Recommended for scenarios where `pool.execute_with_retries ` is insufficient.
81+
82+
83+ Usage of ``pool.execute_with_retries() ``:
84+
85+ .. code-block :: python
86+
87+ pool.execute_with_retries(" DROP TABLE IF EXISTS example" )
88+ pool.execute_with_retries(" CREATE TABLE example(key UInt64, value String, PRIMARY KEY (key))" )
89+
90+ pool.execute_with_retries(" INSERT INTO example (key, value) VALUES (1, 'luffy')" )
91+
92+ res = pool.execute_with_retries(" SELECT COUNT(*) AS rows_count FROM example" )
93+
94+ >>> res[0 ].rows_count
95+ 1
96+
97+ Example of ``tx.execute() ``:
98+
99+ .. code-block :: python
100+
101+ def callee (session : ydb.QuerySessionSync):
102+ with session.transaction() as tx:
103+ with tx.execute(
104+ " INSERT INTO example (key, value) VALUES (2, 'zoro')"
105+ ):
106+ pass
107+
108+ with tx.execute(
109+ " INSERT INTO example (key, value) VALUES (3, 'sanji')" ,
110+ commit_tx = True ,
111+ ):
112+ pass
113+
114+ pool.retry_operation_sync(callee)
115+
116+
54117
55- >>> print (" hello world" )
56- hello world
0 commit comments