MCPcopy
hub / github.com/psycopg/psycopg / _execute_send

Method _execute_send

psycopg/psycopg/_cursor_base.py:416–459  ·  view source on GitHub ↗

Implement part of execute() before waiting common to sync and async. This is not a generator, but a normal non-blocking function.

(
        self,
        query: PostgresQuery,
        *,
        force_extended: bool = False,
        binary: bool | None = None,
    )

Source from the content-addressed store, hash-verified

414 self._set_results(results)
415
416 def _execute_send(
417 self,
418 query: PostgresQuery,
419 *,
420 force_extended: bool = False,
421 binary: bool | None = None,
422 ) -> None:
423 """
424 Implement part of execute() before waiting common to sync and async.
425
426 This is not a generator, but a normal non-blocking function.
427 """
428 if binary is None:
429 fmt = self.format
430 else:
431 fmt = BINARY if binary else TEXT
432
433 self._query = query
434
435 if self._conn._pipeline:
436 # In pipeline mode always use PQsendQueryParams - see #314
437 # Multiple statements in the same query are not allowed anyway.
438 self._conn._pipeline.command_queue.append(
439 partial(
440 self._pgconn.send_query_params,
441 query.query,
442 query.params,
443 param_formats=query.formats,
444 param_types=query.types,
445 result_format=fmt,
446 )
447 )
448 elif force_extended or query.params or fmt == BINARY:
449 self._pgconn.send_query_params(
450 query.query,
451 query.params,
452 param_formats=query.formats,
453 param_types=query.types,
454 result_format=fmt,
455 )
456 else:
457 # If we can, let's use simple query protocol,
458 # as it can execute more than one statement in a single query.
459 self._pgconn.send_query(query.query)
460
461 def _convert_query(
462 self, query: Query, params: Params | None = None

Callers 4

_maybe_prepare_genMethod · 0.95
_stream_send_genMethod · 0.95
_start_copy_genMethod · 0.95
_declare_genMethod · 0.45

Calls 2

send_query_paramsMethod · 0.45
send_queryMethod · 0.45

Tested by

no test coverage detected