Represent the components of a URL used to connect to a database. URLs are typically constructed from a fully formatted URL string, where the :func:`.make_url` function is used internally by the :func:`_sa.create_engine` function in order to parse the URL string into its individ
| 44 | |
| 45 | |
| 46 | class URL(NamedTuple): |
| 47 | """ |
| 48 | Represent the components of a URL used to connect to a database. |
| 49 | |
| 50 | URLs are typically constructed from a fully formatted URL string, where the |
| 51 | :func:`.make_url` function is used internally by the |
| 52 | :func:`_sa.create_engine` function in order to parse the URL string into |
| 53 | its individual components, which are then used to construct a new |
| 54 | :class:`.URL` object. When parsing from a formatted URL string, the parsing |
| 55 | format generally follows |
| 56 | `RFC-1738 <https://www.ietf.org/rfc/rfc1738.txt>`_, with some exceptions. |
| 57 | |
| 58 | A :class:`_engine.URL` object may also be produced directly, either by |
| 59 | using the :func:`.make_url` function with a fully formed URL string, or |
| 60 | by using the :meth:`_engine.URL.create` constructor in order |
| 61 | to construct a :class:`_engine.URL` programmatically given individual |
| 62 | fields. The resulting :class:`.URL` object may be passed directly to |
| 63 | :func:`_sa.create_engine` in place of a string argument, which will bypass |
| 64 | the usage of :func:`.make_url` within the engine's creation process. |
| 65 | |
| 66 | .. versionchanged:: 1.4 |
| 67 | |
| 68 | The :class:`_engine.URL` object is now an immutable object. To |
| 69 | create a URL, use the :func:`_engine.make_url` or |
| 70 | :meth:`_engine.URL.create` function / method. To modify |
| 71 | a :class:`_engine.URL`, use methods like |
| 72 | :meth:`_engine.URL.set` and |
| 73 | :meth:`_engine.URL.update_query_dict` to return a new |
| 74 | :class:`_engine.URL` object with modifications. See notes for this |
| 75 | change at :ref:`change_5526`. |
| 76 | |
| 77 | .. seealso:: |
| 78 | |
| 79 | :ref:`database_urls` |
| 80 | |
| 81 | :class:`_engine.URL` contains the following attributes: |
| 82 | |
| 83 | * :attr:`_engine.URL.drivername`: database backend and driver name, such as |
| 84 | ``postgresql+psycopg2`` |
| 85 | * :attr:`_engine.URL.username`: username string |
| 86 | * :attr:`_engine.URL.password`: password string |
| 87 | * :attr:`_engine.URL.host`: string hostname |
| 88 | * :attr:`_engine.URL.port`: integer port number |
| 89 | * :attr:`_engine.URL.database`: string database name |
| 90 | * :attr:`_engine.URL.query`: an immutable mapping representing the query |
| 91 | string. contains strings for keys and either strings or tuples of |
| 92 | strings for values. |
| 93 | |
| 94 | |
| 95 | """ |
| 96 | |
| 97 | drivername: str |
| 98 | """database backend and driver name, such as |
| 99 | ``postgresql+psycopg2`` |
| 100 | |
| 101 | """ |
| 102 | |
| 103 | username: Optional[str] |
no outgoing calls
no test coverage detected