MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / update_query_dict

Method update_query_dict

lib/sqlalchemy/engine/url.py:484–533  ·  view source on GitHub ↗

Return a new :class:`_engine.URL` object with the :attr:`_engine.URL.query` parameter dictionary updated by the given dictionary. The dictionary typically contains string keys and string values. In order to represent a query parameter that is expressed multiple

(
        self,
        query_parameters: Mapping[str, Union[str, List[str]]],
        append: bool = False,
    )

Source from the content-addressed store, hash-verified

482 return self.set(query=new_query)
483
484 def update_query_dict(
485 self,
486 query_parameters: Mapping[str, Union[str, List[str]]],
487 append: bool = False,
488 ) -> URL:
489 """Return a new :class:`_engine.URL` object with the
490 :attr:`_engine.URL.query` parameter dictionary updated by the given
491 dictionary.
492
493 The dictionary typically contains string keys and string values.
494 In order to represent a query parameter that is expressed multiple
495 times, pass a sequence of string values.
496
497 E.g.::
498
499
500 >>> from sqlalchemy.engine import make_url
501 >>> url = make_url("postgresql+psycopg2://user:pass@host/dbname")
502 >>> url = url.update_query_dict(
503 ... {"alt_host": ["host1", "host2"], "ssl_cipher": "/path/to/crt"}
504 ... )
505 >>> str(url)
506 'postgresql+psycopg2://user:pass@host/dbname?alt_host=host1&alt_host=host2&ssl_cipher=%2Fpath%2Fto%2Fcrt'
507
508
509 :param query_parameters: A dictionary with string keys and values
510 that are either strings, or sequences of strings.
511
512 :param append: if True, parameters in the existing query string will
513 not be removed; new parameters will be in addition to those present.
514 If left at its default of False, keys present in the given query
515 parameters will replace those of the existing query string.
516
517
518 .. versionadded:: 1.4
519
520 .. seealso::
521
522 :attr:`_engine.URL.query`
523
524 :meth:`_engine.URL.update_query_string`
525
526 :meth:`_engine.URL.update_query_pairs`
527
528 :meth:`_engine.URL.difference_update_query`
529
530 :meth:`_engine.URL.set`
531
532 """ # noqa: E501
533 return self.update_query_pairs(query_parameters.items(), append=append)
534
535 def difference_update_query(self, names: Iterable[str]) -> URL:
536 """

Callers 2

generate_driver_urlFunction · 0.80

Calls 2

update_query_pairsMethod · 0.95
itemsMethod · 0.45

Tested by 1