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

Method fetchmany

asyncpg/connection.py:786–827  ·  view source on GitHub ↗

Run a query for each sequence of arguments in *args* and return the results as a list of :class:`Record`. :param query: Query to execute. :param args: An iterable containing sequences of arguments for the query. :param float timeout:

(
        self,
        query,
        args,
        *,
        timeout: typing.Optional[float]=None,
        record_class=None,
    )

Source from the content-addressed store, hash-verified

784 return data[0]
785
786 async def fetchmany(
787 self,
788 query,
789 args,
790 *,
791 timeout: typing.Optional[float]=None,
792 record_class=None,
793 ):
794 """Run a query for each sequence of arguments in *args*
795 and return the results as a list of :class:`Record`.
796
797 :param query:
798 Query to execute.
799 :param args:
800 An iterable containing sequences of arguments for the query.
801 :param float timeout:
802 Optional timeout value in seconds.
803 :param type record_class:
804 If specified, the class to use for records returned by this method.
805 Must be a subclass of :class:`~asyncpg.Record`. If not specified,
806 a per-connection *record_class* is used.
807
808 :return list:
809 A list of :class:`~asyncpg.Record` instances. If specified, the
810 actual type of list elements would be *record_class*.
811
812 Example:
813
814 .. code-block:: pycon
815
816 >>> rows = await con.fetchmany('''
817 ... INSERT INTO mytab (a, b) VALUES ($1, $2) RETURNING a;
818 ... ''', [('x', 1), ('y', 2), ('z', 3)])
819 >>> rows
820 [<Record row=('x',)>, <Record row=('y',)>, <Record row=('z',)>]
821
822 .. versionadded:: 0.30.0
823 """
824 self._check_open()
825 return await self._executemany(
826 query, args, timeout, return_rows=True, record_class=record_class
827 )
828
829 async def copy_from_table(self, table_name, *, output,
830 columns=None, schema_name=None, timeout=None,

Callers

nothing calls this directly

Calls 2

_check_openMethod · 0.95
_executemanyMethod · 0.95

Tested by

no test coverage detected