Copy table contents to a file or file-like object. :param str table_name: The name of the table to copy data from. :param output: A :term:`path-like object `, or a :term:`file-like object `, or
(self, table_name, *, output,
columns=None, schema_name=None, timeout=None,
format=None, oids=None, delimiter=None,
null=None, header=None, quote=None,
escape=None, force_quote=None, encoding=None)
| 827 | ) |
| 828 | |
| 829 | async def copy_from_table(self, table_name, *, output, |
| 830 | columns=None, schema_name=None, timeout=None, |
| 831 | format=None, oids=None, delimiter=None, |
| 832 | null=None, header=None, quote=None, |
| 833 | escape=None, force_quote=None, encoding=None): |
| 834 | """Copy table contents to a file or file-like object. |
| 835 | |
| 836 | :param str table_name: |
| 837 | The name of the table to copy data from. |
| 838 | |
| 839 | :param output: |
| 840 | A :term:`path-like object <python:path-like object>`, |
| 841 | or a :term:`file-like object <python:file-like object>`, or |
| 842 | a :term:`coroutine function <python:coroutine function>` |
| 843 | that takes a ``bytes`` instance as a sole argument. |
| 844 | |
| 845 | :param list columns: |
| 846 | An optional list of column names to copy. |
| 847 | |
| 848 | :param str schema_name: |
| 849 | An optional schema name to qualify the table. |
| 850 | |
| 851 | :param float timeout: |
| 852 | Optional timeout value in seconds. |
| 853 | |
| 854 | The remaining keyword arguments are ``COPY`` statement options, |
| 855 | see `COPY statement documentation`_ for details. |
| 856 | |
| 857 | :return: The status string of the COPY command. |
| 858 | |
| 859 | Example: |
| 860 | |
| 861 | .. code-block:: pycon |
| 862 | |
| 863 | >>> import asyncpg |
| 864 | >>> import asyncio |
| 865 | >>> async def run(): |
| 866 | ... con = await asyncpg.connect(user='postgres') |
| 867 | ... result = await con.copy_from_table( |
| 868 | ... 'mytable', columns=('foo', 'bar'), |
| 869 | ... output='file.csv', format='csv') |
| 870 | ... print(result) |
| 871 | ... |
| 872 | >>> asyncio.run(run()) |
| 873 | 'COPY 100' |
| 874 | |
| 875 | .. _`COPY statement documentation`: |
| 876 | https://www.postgresql.org/docs/current/static/sql-copy.html |
| 877 | |
| 878 | .. versionadded:: 0.11.0 |
| 879 | """ |
| 880 | tabname = utils._quote_ident(table_name) |
| 881 | if schema_name: |
| 882 | tabname = utils._quote_ident(schema_name) + '.' + tabname |
| 883 | |
| 884 | if columns: |
| 885 | cols = '({})'.format( |
| 886 | ', '.join(utils._quote_ident(c) for c in columns)) |
nothing calls this directly
no test coverage detected