Initiate a :sql:`COPY` operation and return an object to manage it.
(
self,
statement: Query,
params: Params | None = None,
*,
writer: Writer | None = None,
)
| 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 ( |