@@ -378,11 +378,25 @@ async def copy_from_table(self, table_name, *, output,
378378
379379 :return: The status string of the COPY command.
380380
381- .. versionadded:: 0.11.0
381+ Example:
382+
383+ .. code-block:: pycon
384+
385+ >>> import asyncpg
386+ >>> import asyncio
387+ >>> async def run():
388+ ... con = await asyncpg.connect(user='postgres')
389+ ... result = await con.copy_from_table(
390+ ... 'mytable', columns=('foo', 'bar'),
391+ ... output='file.csv', format='csv')
392+ ... print(result)
393+ >>> asyncio.get_event_loop().run_until_complete(run())
394+ 'COPY 100'
382395
383396 .. _`COPY statement documentation`: https://www.postgresql.org/docs/\
384397 current/static/sql-copy.html
385398
399+ .. versionadded:: 0.11.0
386400 """
387401 tabname = utils ._quote_ident (table_name )
388402 if schema_name :
@@ -415,7 +429,7 @@ async def copy_from_query(self, query, *args, output,
415429 :param str query:
416430 The query to copy the results of.
417431
418- :param *args:
432+ :param \ *args:
419433 Query arguments.
420434
421435 :param output:
@@ -432,11 +446,25 @@ async def copy_from_query(self, query, *args, output,
432446
433447 :return: The status string of the COPY command.
434448
435- .. versionadded:: 0.11.0
449+ Example:
450+
451+ .. code-block:: pycon
452+
453+ >>> import asyncpg
454+ >>> import asyncio
455+ >>> async def run():
456+ ... con = await asyncpg.connect(user='postgres')
457+ ... result = await con.copy_from_query(
458+ ... 'SELECT foo, bar FROM mytable WHERE foo > $1', 10,
459+ ... output='file.csv', format='csv')
460+ ... print(result)
461+ >>> asyncio.get_event_loop().run_until_complete(run())
462+ 'COPY 10'
436463
437464 .. _`COPY statement documentation`: https://www.postgresql.org/docs/\
438465 current/static/sql-copy.html
439466
467+ .. versionadded:: 0.11.0
440468 """
441469 opts = self ._format_copy_opts (
442470 format = format , oids = oids , delimiter = delimiter ,
@@ -469,7 +497,7 @@ async def copy_to_table(self, table_name, *, source,
469497 or a :term:`file-like object <python:file-like object>`, or
470498 an :term:`asynchronous iterable <python:asynchronous iterable>`
471499 that returns ``bytes``, or an object supporting the
472- :term :`buffer protocol <python:buffer protocol >`.
500+ :ref :`buffer protocol <python:bufferobjects >`.
473501
474502 :param list columns:
475503 An optional list of column names to copy.
@@ -485,11 +513,24 @@ async def copy_to_table(self, table_name, *, source,
485513
486514 :return: The status string of the COPY command.
487515
488- .. versionadded:: 0.11.0
516+ Example:
517+
518+ .. code-block:: pycon
519+
520+ >>> import asyncpg
521+ >>> import asyncio
522+ >>> async def run():
523+ ... con = await asyncpg.connect(user='postgres')
524+ ... result = await con.copy_to_table(
525+ ... 'mytable', source='datafile.tbl')
526+ .... print(result)
527+ >>> asyncio.get_event_loop().run_until_complete(run())
528+ 'COPY 140000'
489529
490530 .. _`COPY statement documentation`: https://www.postgresql.org/docs/\
491531 current/static/sql-copy.html
492532
533+ .. versionadded:: 0.11.0
493534 """
494535 tabname = utils ._quote_ident (table_name )
495536 if schema_name :
@@ -535,6 +576,22 @@ async def copy_records_to_table(self, table_name, *, records,
535576
536577 :return: The status string of the COPY command.
537578
579+ Example:
580+
581+ .. code-block:: pycon
582+
583+ >>> import asyncpg
584+ >>> import asyncio
585+ >>> async def run():
586+ ... con = await asyncpg.connect(user='postgres')
587+ ... result = await con.copy_records_to_table(
588+ ... 'mytable', records=[
589+ ... (1, 'foo', 'bar'),
590+ ... (2, 'ham', 'spam')])
591+ .... print(result)
592+ >>> asyncio.get_event_loop().run_until_complete(run())
593+ 'COPY 2'
594+
538595 .. versionadded:: 0.11.0
539596 """
540597 tabname = utils ._quote_ident (table_name )
0 commit comments