Create a *prepared statement* for the specified query. :param str query: Text of the query to create a prepared statement for. :param str name: Optional name of the returned prepared statement. If not specified, the name is auto-generated.
(
self,
query,
*,
name=None,
timeout=None,
record_class=None,
)
| 604 | ) |
| 605 | |
| 606 | async def prepare( |
| 607 | self, |
| 608 | query, |
| 609 | *, |
| 610 | name=None, |
| 611 | timeout=None, |
| 612 | record_class=None, |
| 613 | ): |
| 614 | """Create a *prepared statement* for the specified query. |
| 615 | |
| 616 | :param str query: |
| 617 | Text of the query to create a prepared statement for. |
| 618 | :param str name: |
| 619 | Optional name of the returned prepared statement. If not |
| 620 | specified, the name is auto-generated. |
| 621 | :param float timeout: |
| 622 | Optional timeout value in seconds. |
| 623 | :param type record_class: |
| 624 | If specified, the class to use for records returned by the |
| 625 | prepared statement. Must be a subclass of |
| 626 | :class:`~asyncpg.Record`. If not specified, a per-connection |
| 627 | *record_class* is used. |
| 628 | |
| 629 | :return: |
| 630 | A :class:`~prepared_stmt.PreparedStatement` instance. |
| 631 | |
| 632 | .. versionchanged:: 0.22.0 |
| 633 | Added the *record_class* parameter. |
| 634 | |
| 635 | .. versionchanged:: 0.25.0 |
| 636 | Added the *name* parameter. |
| 637 | """ |
| 638 | return await self._prepare( |
| 639 | query, |
| 640 | name=name, |
| 641 | timeout=timeout, |
| 642 | record_class=record_class, |
| 643 | ) |
| 644 | |
| 645 | async def _prepare( |
| 646 | self, |