Returns a connection to Impala. This is intended to be used in a "with" block. The connection will be closed upon exiting the block. The returned connection will have a 'db_name' property. DEPRECATED: See the 'unique_database' fixture above to use Impala's custom python AP
(pytest_config, db_name=None, timeout=DEFAULT_CONN_TIMEOUT)
| 527 | |
| 528 | @contextlib.contextmanager |
| 529 | def __auto_closed_conn(pytest_config, db_name=None, timeout=DEFAULT_CONN_TIMEOUT): |
| 530 | """Returns a connection to Impala. This is intended to be used in a "with" block. |
| 531 | The connection will be closed upon exiting the block. |
| 532 | |
| 533 | The returned connection will have a 'db_name' property. |
| 534 | |
| 535 | DEPRECATED: |
| 536 | See the 'unique_database' fixture above to use Impala's custom python |
| 537 | API instead of DB-API. |
| 538 | """ |
| 539 | default_impalad = pytest_config.option.impalad.split(',')[0] |
| 540 | impalad_host = default_impalad.split(':')[0] |
| 541 | hs2_port = pytest_config.option.impalad_hs2_port |
| 542 | |
| 543 | conn = impala_connect(host=impalad_host, port=hs2_port, database=db_name, |
| 544 | timeout=timeout) |
| 545 | try: |
| 546 | conn.db_name = db_name |
| 547 | yield conn |
| 548 | finally: |
| 549 | try: |
| 550 | conn.close() |
| 551 | except Exception as e: |
| 552 | LOG.warn("Error closing Impala connection: %s", e) |
| 553 | |
| 554 | |
| 555 | @pytest.fixture |
no test coverage detected