@@ -134,6 +134,54 @@ def callee(session):
134134
135135
136136def select_prepared (pool , path , series_id , season_id , episode_id ):
137+ def callee (session ):
138+ query = """
139+ PRAGMA TablePathPrefix("{}");
140+
141+ DECLARE $seriesId AS Uint64;
142+ DECLARE $seasonId AS Uint64;
143+ DECLARE $episodeId AS Uint64;
144+
145+ $format = DateTime::Format("%Y-%m-%d");
146+ SELECT
147+ title,
148+ $format(DateTime::FromSeconds(CAST(DateTime::ToSeconds(DateTime::IntervalFromDays(CAST(air_date AS Int16))) AS Uint32))) AS air_date
149+ FROM episodes
150+ WHERE series_id = $seriesId AND season_id = $seasonId AND episode_id = $episodeId;
151+ """ .format (
152+ path
153+ )
154+
155+ data_query = ydb .types .DataQuery (
156+ query ,
157+ parameters_types = {
158+ '$seriesId' : ydb .types .PrimitiveType .Uint64 ,
159+ '$seasonId' : ydb .types .PrimitiveType .Uint64 ,
160+ '$episodeId' : ydb .types .PrimitiveType .Uint64 ,
161+ }
162+ )
163+
164+ result_sets = session .transaction (ydb .SerializableReadWrite ()).execute (
165+ data_query ,
166+ {
167+ "$seriesId" : series_id ,
168+ "$seasonId" : season_id ,
169+ "$episodeId" : episode_id ,
170+ },
171+ commit_tx = True ,
172+ settings = ydb .table .ExecDataQuerySettings ().with_keep_in_cache (True ),
173+ )
174+ print ("\n > select_prepared_transaction:" )
175+ for row in result_sets [0 ].rows :
176+ print ("episode title:" , row .title , ", air date:" , row .air_date )
177+
178+ return result_sets [0 ]
179+
180+ return pool .retry_operation_sync (callee )
181+
182+
183+ # Prepared query with session-based cache (obsolete)
184+ def select_prepared_session_based (pool , path , series_id , season_id , episode_id ):
137185 def callee (session ):
138186 query = """
139187 PRAGMA TablePathPrefix("{}");
0 commit comments