MCPcopy
hub / github.com/psycopg/psycopg / copy

Method copy

psycopg/psycopg/cursor.py:313–334  ·  view source on GitHub ↗

Initiate a :sql:`COPY` operation and return an object to manage it.

(
        self,
        statement: Query,
        params: Params | None = None,
        *,
        writer: Writer | None = None,
    )

Source from the content-addressed store, hash-verified

311
312 @contextmanager
313 def copy(
314 self,
315 statement: Query,
316 params: Params | None = None,
317 *,
318 writer: Writer | None = None,
319 ) -> Iterator[Copy]:
320 """
321 Initiate a :sql:`COPY` operation and return an object to manage it.
322 """
323 try:
324 with self._conn.lock:
325 self._conn.wait(self._start_copy_gen(statement, params))
326
327 with Copy(self, writer=writer) as copy:
328 yield copy
329 except e._NO_TRACEBACK as ex:
330 raise ex.with_traceback(None)
331
332 # If a fresher result has been set on the cursor by the Copy object,
333 # read its properties (especially rowcount).
334 self._select_current_result(0)
335
336 def _fetch_pipeline(self) -> None:
337 if (

Callers 15

_connectMethod · 0.45
_connectMethod · 0.45
test_copy_out_readFunction · 0.45
test_copy_out_iterFunction · 0.45
test_copy_out_no_resultFunction · 0.45
test_copy_out_paramFunction · 0.45
test_read_rowsFunction · 0.45
test_rowsFunction · 0.45
test_set_typesFunction · 0.45
test_rowlen_mismatchFunction · 0.45
test_set_custom_typeFunction · 0.45
test_copy_out_allcharsFunction · 0.45

Calls 4

CopyClass · 0.85
_start_copy_genMethod · 0.80
waitMethod · 0.45

Tested by 15

test_copy_out_readFunction · 0.36
test_copy_out_iterFunction · 0.36
test_copy_out_no_resultFunction · 0.36
test_copy_out_paramFunction · 0.36
test_read_rowsFunction · 0.36
test_rowsFunction · 0.36
test_set_typesFunction · 0.36
test_rowlen_mismatchFunction · 0.36
test_set_custom_typeFunction · 0.36
test_copy_out_allcharsFunction · 0.36
test_read_row_notypesFunction · 0.36
test_rows_notypesFunction · 0.36