MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / update_query_string

Method update_query_string

lib/sqlalchemy/engine/url.py:366–399  ·  view source on GitHub ↗

Return a new :class:`_engine.URL` object with the :attr:`_engine.URL.query` parameter dictionary updated by the given query string. E.g.:: >>> from sqlalchemy.engine import make_url >>> url = make_url("postgresql+psycopg2://user:pass@host/dbname")

(
        self, query_string: str, append: bool = False
    )

Source from the content-addressed store, hash-verified

364 return self._replace(**kw)
365
366 def update_query_string(
367 self, query_string: str, append: bool = False
368 ) -> URL:
369 """Return a new :class:`_engine.URL` object with the :attr:`_engine.URL.query`
370 parameter dictionary updated by the given query string.
371
372 E.g.::
373
374 >>> from sqlalchemy.engine import make_url
375 >>> url = make_url("postgresql+psycopg2://user:pass@host/dbname")
376 >>> url = url.update_query_string(
377 ... "alt_host=host1&alt_host=host2&ssl_cipher=%2Fpath%2Fto%2Fcrt"
378 ... )
379 >>> str(url)
380 'postgresql+psycopg2://user:pass@host/dbname?alt_host=host1&alt_host=host2&ssl_cipher=%2Fpath%2Fto%2Fcrt'
381
382 :param query_string: a URL escaped query string, not including the
383 question mark.
384
385 :param append: if True, parameters in the existing query string will
386 not be removed; new parameters will be in addition to those present.
387 If left at its default of False, keys present in the given query
388 parameters will replace those of the existing query string.
389
390 .. versionadded:: 1.4
391
392 .. seealso::
393
394 :attr:`_engine.URL.query`
395
396 :meth:`_engine.URL.update_query_dict`
397
398 """ # noqa: E501
399 return self.update_query_pairs(parse_qsl(query_string), append=append)
400
401 def update_query_pairs(
402 self,

Callers 4

generate_driver_urlFunction · 0.80
generate_driver_urlFunction · 0.80
generate_driver_urlFunction · 0.80

Calls 1

update_query_pairsMethod · 0.95

Tested by 1