1- #
2- # Licensed under the Apache License, Version 2.0 (the "License"); you may
3- # not use this file except in compliance with the License. You may obtain
4- # a copy of the License at
5- #
6- # http://www.apache.org/licenses/LICENSE-2.0
7- #
8- # Unless required by applicable law or agreed to in writing, software
9- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11- # License for the specific language governing permissions and limitations
12- # under the License.
131import logging
142from typing import Any , Optional
153from urllib .parse import quote , urlencode
3018 logger .debug ("SQLAlchemy not available, skipping DBAPIError handling" )
3119
3220
33- class DbContainer (DockerContainer ):
21+ class SqlContainer (DockerContainer ):
3422 """
35- Generic database container providing common database functionality.
23+ Generic SQL database container providing common functionality.
3624
37- This class serves as a base for database-specific container implementations.
25+ This class can serve as a base for database-specific container implementations.
3826 It provides connection management, URL construction, and basic lifecycle methods.
39-
40- Note:
41- This class is deprecated and will be removed in a future version.
42- Use database-specific container classes instead.
4327 """
4428
4529 @wait_container_is_ready (* ADDITIONAL_TRANSIENT_ERRORS )
@@ -58,7 +42,6 @@ def _connect(self) -> None:
5842 raise ImportError ("SQLAlchemy is required for database containers" ) from e
5943
6044 connection_url = self .get_connection_url ()
61- logger .debug (f"Testing database connection to { self ._mask_password_in_url (connection_url )} " )
6245
6346 engine = sqlalchemy .create_engine (connection_url )
6447 try :
@@ -147,33 +130,14 @@ def _create_connection_url(
147130 query_string = urlencode (query_params )
148131 url = f"{ url } ?{ query_string } "
149132
150- logger .debug (f"Created connection URL: { self ._mask_password_in_url (url )} " )
151133 return url
152134
153- def _mask_password_in_url (self , url : str ) -> str :
154- """
155- Mask password in URL for safe logging.
156-
157- Args:
158- url: Database connection URL
159-
160- Returns:
161- str: URL with masked password
162- """
163- try :
164- # Simple regex-based masking for logging
165- import re
166-
167- return re .sub (r"://([^:]+):([^@]+)@" , r"://\1:***@" , url )
168- except Exception :
169- return "[URL with masked credentials]"
170-
171- def start (self ) -> "DbContainer" :
135+ def start (self ) -> "SqlContainer" :
172136 """
173137 Start the database container and perform initialization.
174138
175139 Returns:
176- DbContainer : Self for method chaining
140+ SqlContainer : Self for method chaining
177141
178142 Raises:
179143 ContainerStartException: If container fails to start
0 commit comments