MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / prepare

Method prepare

asyncpg/connection.py:629–666  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

627 )
628
629 async def prepare(
630 self,
631 query,
632 *,
633 name=None,
634 timeout=None,
635 record_class=None,
636 ):
637 """Create a *prepared statement* for the specified query.
638
639 :param str query:
640 Text of the query to create a prepared statement for.
641 :param str name:
642 Optional name of the returned prepared statement. If not
643 specified, the name is auto-generated.
644 :param float timeout:
645 Optional timeout value in seconds.
646 :param type record_class:
647 If specified, the class to use for records returned by the
648 prepared statement. Must be a subclass of
649 :class:`~asyncpg.Record`. If not specified, a per-connection
650 *record_class* is used.
651
652 :return:
653 A :class:`~prepared_stmt.PreparedStatement` instance.
654
655 .. versionchanged:: 0.22.0
656 Added the *record_class* parameter.
657
658 .. versionchanged:: 0.25.0
659 Added the *name* parameter.
660 """
661 return await self._prepare(
662 query,
663 name=name,
664 timeout=timeout,
665 record_class=record_class,
666 )
667
668 async def _prepare(
669 self,

Callers 2

_get_statementMethod · 0.45
_mogrifyFunction · 0.45

Calls 1

_prepareMethod · 0.95

Tested by

no test coverage detected