Copy data to the specified table. :param str table_name: The name of the table to copy data to. :param source: A :term:`path-like object `, or a :term:`file-like object `, or an :term:
(self, table_name, *, source,
columns=None, schema_name=None, timeout=None,
format=None, oids=None, freeze=None,
delimiter=None, null=None, header=None,
quote=None, escape=None, force_quote=None,
force_not_null=None, force_null=None,
encoding=None, where=None)
| 938 | return await self._copy_out(copy_stmt, output, timeout) |
| 939 | |
| 940 | async def copy_to_table(self, table_name, *, source, |
| 941 | columns=None, schema_name=None, timeout=None, |
| 942 | format=None, oids=None, freeze=None, |
| 943 | delimiter=None, null=None, header=None, |
| 944 | quote=None, escape=None, force_quote=None, |
| 945 | force_not_null=None, force_null=None, |
| 946 | encoding=None, where=None): |
| 947 | """Copy data to the specified table. |
| 948 | |
| 949 | :param str table_name: |
| 950 | The name of the table to copy data to. |
| 951 | |
| 952 | :param source: |
| 953 | A :term:`path-like object <python:path-like object>`, |
| 954 | or a :term:`file-like object <python:file-like object>`, or |
| 955 | an :term:`asynchronous iterable <python:asynchronous iterable>` |
| 956 | that returns ``bytes``, or an object supporting the |
| 957 | :ref:`buffer protocol <python:bufferobjects>`. |
| 958 | |
| 959 | :param list columns: |
| 960 | An optional list of column names to copy. |
| 961 | |
| 962 | :param str schema_name: |
| 963 | An optional schema name to qualify the table. |
| 964 | |
| 965 | :param str where: |
| 966 | An optional SQL expression used to filter rows when copying. |
| 967 | |
| 968 | .. note:: |
| 969 | |
| 970 | Usage of this parameter requires support for the |
| 971 | ``COPY FROM ... WHERE`` syntax, introduced in |
| 972 | PostgreSQL version 12. |
| 973 | |
| 974 | :param float timeout: |
| 975 | Optional timeout value in seconds. |
| 976 | |
| 977 | The remaining keyword arguments are ``COPY`` statement options, |
| 978 | see `COPY statement documentation`_ for details. |
| 979 | |
| 980 | :return: The status string of the COPY command. |
| 981 | |
| 982 | Example: |
| 983 | |
| 984 | .. code-block:: pycon |
| 985 | |
| 986 | >>> import asyncpg |
| 987 | >>> import asyncio |
| 988 | >>> async def run(): |
| 989 | ... con = await asyncpg.connect(user='postgres') |
| 990 | ... result = await con.copy_to_table( |
| 991 | ... 'mytable', source='datafile.tbl') |
| 992 | ... print(result) |
| 993 | ... |
| 994 | >>> asyncio.run(run()) |
| 995 | 'COPY 140000' |
| 996 | |
| 997 | .. _`COPY statement documentation`: |
nothing calls this directly
no test coverage detected