MCPcopy
hub / github.com/MagicStack/asyncpg / prepare

Method prepare

asyncpg/connection.py:606–643  ·  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

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,

Callers 15

copy_records_to_tableMethod · 0.95
test_standard_codecsMethod · 0.80
test_invalid_inputMethod · 0.80
test_arraysMethod · 0.80
test_compositesMethod · 0.80
test_domainsMethod · 0.80
test_range_typesMethod · 0.80
test_multirange_typesMethod · 0.80
test_no_resultMethod · 0.80

Calls 1

_prepareMethod · 0.95

Tested by 15

test_standard_codecsMethod · 0.64
test_invalid_inputMethod · 0.64
test_arraysMethod · 0.64
test_compositesMethod · 0.64
test_domainsMethod · 0.64
test_range_typesMethod · 0.64
test_multirange_typesMethod · 0.64
test_no_resultMethod · 0.64