db_exceptions
DBExceptions
Bases: CoreExceptions
Database specific exceptions that inherit from CoreExceptions.
All database related custom exceptions should be raised through this class.
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
|
raise_invalid_database_type(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when specified database type is not supported.
This method handles cases where the provided database type is not among the supported database systems in the framework.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Validating database type before connection
def validate_db_type(self, db_type): valid_types = ['mysql', 'postgresql', 'oracle'] if db_type not in valid_types: self.exceptions.raise_invalid_database_type(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
raise_null_column_header(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when column headers are missing.
This method is used when database operation requires column headers (e.g., for result processing or data mapping) but they are missing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Processing result columns
def validate_columns(self, headers): if not headers: self.exceptions.raise_null_column_header(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
|
raise_null_database_name(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when database name is missing.
This method is used when a database operation requires a specific database name but none is provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Setting up database connection
def connect_to_database(self, params): if not params.get('database_name'): self.exceptions.raise_null_database_name(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
raise_null_database_object(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when database connection object is null.
This method is used when a database operation is attempted but the database connection object is not properly initialized.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Checking database connection before query
def execute_select(self, query): if not self.db_connection: self.exceptions.raise_null_database_object(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
raise_null_database_type(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when database type is not specified.
This method is used when the type of database (e.g., MySQL, Oracle) is not provided but required for connection setup.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Initializing database connection factory
def initialize_db_connection(self, db_config): if not db_config.get('db_type'): self.exceptions.raise_null_database_type(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
raise_null_dataframe(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when pandas DataFrame is null.
This method handles cases where a pandas DataFrame is required for data processing but is null or empty.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Processing DataFrame
def analyze_data(self, df): if df is None or df.empty: self.exceptions.raise_null_dataframe(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
|
raise_null_filepath(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when file path for database operation is missing.
This method handles cases where a file path is required (e.g., for importing/exporting data) but not provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Importing data from file
def import_data_from_file(self, file_path): if not file_path: self.exceptions.raise_null_filepath(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
|
raise_null_hive_object(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when Hive connection object is null.
This method handles cases where a Hive operation is attempted but the Hive client connection is not properly initialized.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Validating Hive connection
def execute_hive_query(self, query): if not self.hive_client: self.exceptions.raise_null_hive_object(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
|
raise_null_password(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when database password is missing.
This method handles cases where the database password is required but not provided in the connection parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Validating database credentials
def verify_db_credentials(self, credentials): if not credentials.get('password'): self.exceptions.raise_null_password(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
raise_null_query(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when SQL query string is null or empty.
This method is used when attempting to execute a database query but no query string is provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Executing database query
def execute_query(self, query): if not query or not query.strip(): self.exceptions.raise_null_query(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
raise_null_result_list(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when query result list is null.
This method is used when a database query is expected to return a list of results but returns null instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Processing query results
def process_query_results(self, results): if results is None: self.exceptions.raise_null_result_list(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
|
raise_null_result_set(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when query result set is null.
This method handles cases where a database query is expected to return a result set object but returns null instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Handling query result set
def get_result_set(self, query): result_set = self.db.execute(query) if result_set is None: self.exceptions.raise_null_result_set(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
|
raise_null_secret_key(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when database secret key is missing.
This method is used when a secret key required for encrypted database connections or secure operations is not provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Setting up encrypted database connection
def setup_secure_connection(self, config): if not config.get('secret_key'): self.exceptions.raise_null_secret_key(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
raise_null_server_name(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when database server name is null or empty.
This method handles cases where the database server name is missing, which is required for establishing database connections.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Validating database connection parameters
def create_db_connection(self, config): if not config.get('server_name'): self.exceptions.raise_null_server_name(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
raise_null_service_name(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when database service name is missing.
This method is used when a database service name is required (e.g., for Oracle TNS connections) but not provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Setting up Oracle connection
def connect_to_oracle(self, config): if not config.get('service_name'): self.exceptions.raise_null_service_name(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
|
raise_null_table_name(insert_report=True, trim_log=True, log_local=True, fail_test=True)
Raise exception when table name is missing for database operation.
This method handles cases where a table operation is attempted but the target table name is not specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insert_report
|
bool
|
Whether to add exception details to the test report |
True
|
trim_log
|
bool
|
If True, includes only application frames in stack trace |
True
|
log_local
|
bool
|
Whether to enable local logging of the exception |
True
|
fail_test
|
bool
|
If True, marks the current test as failed |
True
|
Example
Performing table operation
def get_table_data(self, table_name): if not table_name: self.exceptions.raise_null_table_name(fail_test=True)
Source code in libs\cafex_db\src\cafex_db\db_exceptions.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|