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)
| 804 | ) |
| 805 | |
| 806 | async def copy_from_table(self, table_name, *, output, |
| 807 | columns=None, schema_name=None, timeout=None, |
| 808 | format=None, oids=None, delimiter=None, |
| 809 | null=None, header=None, quote=None, |
| 810 | escape=None, force_quote=None, encoding=None): |
| 811 | """Copy table contents to a file or file-like object. |
| 812 | |
| 813 | :param str table_name: |
| 814 | The name of the table to copy data from. |
| 815 | |
| 816 | :param output: |
| 817 | A :term:`path-like object <python:path-like object>`, |
| 818 | or a :term:`file-like object <python:file-like object>`, or |
| 819 | a :term:`coroutine function <python:coroutine function>` |
| 820 | that takes a ``bytes`` instance as a sole argument. |
| 821 | |
| 822 | :param list columns: |
| 823 | An optional list of column names to copy. |
| 824 | |
| 825 | :param str schema_name: |
| 826 | An optional schema name to qualify the table. |
| 827 | |
| 828 | :param float timeout: |
| 829 | Optional timeout value in seconds. |
| 830 | |
| 831 | The remaining keyword arguments are ``COPY`` statement options, |
| 832 | see `COPY statement documentation`_ for details. |
| 833 | |
| 834 | :return: The status string of the COPY command. |
| 835 | |
| 836 | Example: |
| 837 | |
| 838 | .. code-block:: pycon |
| 839 | |
| 840 | >>> import asyncpg |
| 841 | >>> import asyncio |
| 842 | >>> async def run(): |
| 843 | ... con = await asyncpg.connect(user='postgres') |
| 844 | ... result = await con.copy_from_table( |
| 845 | ... 'mytable', columns=('foo', 'bar'), |
| 846 | ... output='file.csv', format='csv') |
| 847 | ... print(result) |
| 848 | ... |
| 849 | >>> asyncio.run(run()) |
| 850 | 'COPY 100' |
| 851 | |
| 852 | .. _`COPY statement documentation`: |
| 853 | https://www.postgresql.org/docs/current/static/sql-copy.html |
| 854 | |
| 855 | .. versionadded:: 0.11.0 |
| 856 | """ |
| 857 | tabname = utils._quote_ident(table_name) |
| 858 | if schema_name: |
| 859 | tabname = utils._quote_ident(schema_name) + '.' + tabname |
| 860 | |
| 861 | if columns: |
| 862 | cols = '({})'.format( |
| 863 | ', '.join(utils._quote_ident(c) for c in columns)) |
nothing calls this directly
no test coverage detected