MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / make_url

Function make_url

lib/sqlalchemy/engine/url.py:839–864  ·  view source on GitHub ↗

Given a string, produce a new URL instance. The format of the URL generally follows `RFC-1738 <https://www.ietf.org/rfc/rfc1738.txt>`_, with some exceptions, including that underscores, and not dashes or periods, are accepted within the "scheme" portion. If a :class:`.URL` obje

(name_or_url: Union[str, URL])

Source from the content-addressed store, hash-verified

837
838
839def make_url(name_or_url: Union[str, URL]) -> URL:
840 """Given a string, produce a new URL instance.
841
842 The format of the URL generally follows `RFC-1738
843 <https://www.ietf.org/rfc/rfc1738.txt>`_, with some exceptions, including
844 that underscores, and not dashes or periods, are accepted within the
845 "scheme" portion.
846
847 If a :class:`.URL` object is passed, it is returned as is.
848
849 .. seealso::
850
851 :ref:`database_urls`
852
853 """
854
855 if isinstance(name_or_url, str):
856 return _parse_url(name_or_url)
857 elif not isinstance(name_or_url, URL) and not hasattr(
858 name_or_url, "_sqla_is_testing_if_this_is_a_mock_object"
859 ):
860 raise exc.ArgumentError(
861 f"Expected string or URL object, got {name_or_url!r}"
862 )
863 else:
864 return name_or_url
865
866
867def _parse_url(name: str) -> URL:

Callers 9

testing_engineFunction · 0.90
test_asyncioMethod · 0.90
test_ssl_argumentsMethod · 0.90
test_query_argumentsMethod · 0.90
test_random_argMethod · 0.90
test_mariadb_madnessMethod · 0.90
test_connect_argsMethod · 0.90

Calls 1

_parse_urlFunction · 0.85

Tested by 8

test_asyncioMethod · 0.72
test_ssl_argumentsMethod · 0.72
test_query_argumentsMethod · 0.72
test_random_argMethod · 0.72
test_mariadb_madnessMethod · 0.72
test_connect_argsMethod · 0.72