MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / set

Method set

lib/sqlalchemy/engine/url.py:298–349  ·  view source on GitHub ↗

return a new :class:`_engine.URL` object with modifications. Values are used if they are non-None. To set a value to ``None`` explicitly, use the :meth:`_engine.URL._replace` method adapted from ``namedtuple``. :param drivername: new drivername :param usern

(
        self,
        drivername: Optional[str] = None,
        username: Optional[str] = None,
        password: Optional[str] = None,
        host: Optional[str] = None,
        port: Optional[int] = None,
        database: Optional[str] = None,
        query: Optional[Mapping[str, Union[Sequence[str], str]]] = None,
    )

Source from the content-addressed store, hash-verified

296 )
297
298 def set(
299 self,
300 drivername: Optional[str] = None,
301 username: Optional[str] = None,
302 password: Optional[str] = None,
303 host: Optional[str] = None,
304 port: Optional[int] = None,
305 database: Optional[str] = None,
306 query: Optional[Mapping[str, Union[Sequence[str], str]]] = None,
307 ) -> URL:
308 """return a new :class:`_engine.URL` object with modifications.
309
310 Values are used if they are non-None. To set a value to ``None``
311 explicitly, use the :meth:`_engine.URL._replace` method adapted
312 from ``namedtuple``.
313
314 :param drivername: new drivername
315 :param username: new username
316 :param password: new password
317 :param host: new hostname
318 :param port: new port
319 :param query: new query parameters, passed a dict of string keys
320 referring to string or sequence of string values. Fully
321 replaces the previous list of arguments.
322
323 :return: new :class:`_engine.URL` object.
324
325 .. versionadded:: 1.4
326
327 .. seealso::
328
329 :meth:`_engine.URL.update_query_dict`
330
331 """
332
333 kw: Dict[str, Any] = {}
334 if drivername is not None:
335 kw["drivername"] = drivername
336 if username is not None:
337 kw["username"] = username
338 if password is not None:
339 kw["password"] = password
340 if host is not None:
341 kw["host"] = host
342 if port is not None:
343 kw["port"] = port
344 if database is not None:
345 kw["database"] = database
346 if query is not None:
347 kw["query"] = query
348
349 return self._assert_replace(**kw)
350
351 def _assert_replace(self, **kw: Any) -> URL:
352 """argument checks before calling _replace()"""

Callers 9

update_query_pairsMethod · 0.95
generate_driver_urlFunction · 0.45
generate_driver_urlFunction · 0.45
_format_urlFunction · 0.45
is_preferred_driverFunction · 0.45
generate_driver_urlFunction · 0.45
follower_url_from_mainFunction · 0.45

Calls 1

_assert_replaceMethod · 0.95

Tested by

no test coverage detected