(
self,
query,
timeout,
*,
named: typing.Union[str, bool, None] = False,
use_cache=True,
ignore_custom_codec=False,
record_class=None
)
| 424 | return await self._executemany(command, args, timeout) |
| 425 | |
| 426 | async def _get_statement( |
| 427 | self, |
| 428 | query, |
| 429 | timeout, |
| 430 | *, |
| 431 | named: typing.Union[str, bool, None] = False, |
| 432 | use_cache=True, |
| 433 | ignore_custom_codec=False, |
| 434 | record_class=None |
| 435 | ): |
| 436 | if record_class is None: |
| 437 | record_class = self._protocol.get_record_class() |
| 438 | else: |
| 439 | _check_record_class(record_class) |
| 440 | |
| 441 | if use_cache: |
| 442 | statement = self._stmt_cache.get( |
| 443 | (query, record_class, ignore_custom_codec) |
| 444 | ) |
| 445 | if statement is not None: |
| 446 | return statement |
| 447 | |
| 448 | # Only use the cache when: |
| 449 | # * `statement_cache_size` is greater than 0; |
| 450 | # * query size is less than `max_cacheable_statement_size`. |
| 451 | use_cache = ( |
| 452 | self._stmt_cache_enabled |
| 453 | and ( |
| 454 | not self._config.max_cacheable_statement_size |
| 455 | or len(query) <= self._config.max_cacheable_statement_size |
| 456 | ) |
| 457 | ) |
| 458 | |
| 459 | if isinstance(named, str): |
| 460 | stmt_name = named |
| 461 | elif use_cache or named: |
| 462 | stmt_name = self._get_unique_id('stmt') |
| 463 | else: |
| 464 | stmt_name = '' |
| 465 | |
| 466 | statement = await self._protocol.prepare( |
| 467 | stmt_name, |
| 468 | query, |
| 469 | timeout, |
| 470 | record_class=record_class, |
| 471 | ignore_custom_codec=ignore_custom_codec, |
| 472 | ) |
| 473 | need_reprepare = False |
| 474 | types_with_missing_codecs = statement._init_types() |
| 475 | tries = 0 |
| 476 | while types_with_missing_codecs: |
| 477 | settings = self._protocol.get_settings() |
| 478 | |
| 479 | # Introspect newly seen types and populate the |
| 480 | # codec cache. |
| 481 | types, intro_stmt = await self._introspect_types( |
| 482 | types_with_missing_codecs, timeout) |
| 483 |
no test coverage detected