def __init__(self, options=None):
    self.parameters = {}
    self.session_id = None
    self.backend_pid = None
    self.backend_key = None
    self.transaction_status = None
    self.socket = None
    self.socket_as_file = None
    options = (options or {})
    self.options = (parse_dsn(options['dsn']) if ('dsn' in options) else {})
    self.options.update({key: value for (key, value) in options.items() if ((key == 'log_path') or ((key != 'dsn') and (value is not None)))})
    logger_name = 'vertica_{0}_{1}'.format(id(self), str(uuid.uuid4()))
    self._logger = logging.getLogger(logger_name)
    if (('log_level' not in self.options) and ('log_path' not in self.options)):
        self._logger.disabled = True
    else:
        self.options.setdefault('log_level', DEFAULT_LOG_LEVEL)
        self.options.setdefault('log_path', DEFAULT_LOG_PATH)
        VerticaLogging.setup_logging(logger_name, self.options['log_path'], self.options['log_level'], id(self))
    self.options.setdefault('host', DEFAULT_HOST)
    self.options.setdefault('port', DEFAULT_PORT)
    if ('user' not in self.options):
        if DEFAULT_USER:
            self.options['user'] = DEFAULT_USER
        else:
            msg = 'Connection option "user" is required'
            self._logger.error(msg)
            raise KeyError(msg)
    self.options.setdefault('database', self.options['user'])
    self.options.setdefault('password', DEFAULT_PASSWORD)
    self.options.setdefault('autocommit', DEFAULT_AUTOCOMMIT)
    self.options.setdefault('session_label', _generate_session_label())
    self.options.setdefault('backup_server_node', DEFAULT_BACKUP_SERVER_NODE)
    self.options.setdefault('kerberos_service_name', DEFAULT_KRB_SERVICE_NAME)
    self.options.setdefault('kerberos_host_name', self.options['host'])
    self.address_list = _AddressList(self.options['host'], self.options['port'], self.options['backup_server_node'], self._logger)
    self.options.setdefault('unicode_error', None)
    self._cursor = Cursor(self, self._logger, cursor_type=None, unicode_error=self.options['unicode_error'])
    self.options.setdefault('use_prepared_statements', False)
    self._logger.debug('Connection prepared statements is {}'.format(('enabled' if self.options['use_prepared_statements'] else 'disabled')))
    self.options.setdefault('disable_copy_local', False)
    self._logger.debug('COPY LOCAL operation is {}'.format(('disabled' if self.options['disable_copy_local'] else 'enabled')))
    self._logger.info('Connecting as user "{}" to database "{}" on host "{}" with port {}'.format(self.options['user'], self.options['database'], self.options['host'], self.options['port']))
    self.startup_connection()
    if self.options['autocommit']:
        self.autocommit = True
    self._logger.info('Connection is ready')
def __init__(self, options=None):
    self.parameters = {}
    self.session_id = None
    self.backend_pid = None
    self.backend_key = None
    self.transaction_status = None
    self.socket = None
    self.socket_as_file = None
    options = (options or {})
    self.options = (parse_dsn(options['dsn']) if ('dsn' in options) else {})
    self.options.update({key: value for (key, value) in options.items() if ((key == 'log_path') or ((key != 'dsn') and (value is not None)))})
    logger_name = 'vertica_{0}_{1}'.format(id(self), str(uuid.uuid4()))
    self._logger = logging.getLogger(logger_name)
    if (('log_level' not in self.options) and ('log_path' not in self.options)):
        self._logger.disabled = True
    else:
        self.options.setdefault('log_level', DEFAULT_LOG_LEVEL)
        self.options.setdefault('log_path', DEFAULT_LOG_PATH)
        VerticaLogging.setup_logging(logger_name, self.options['log_path'], self.options['log_level'], id(self))
    self.options.setdefault('host', DEFAULT_HOST)
    self.options.setdefault('port', DEFAULT_PORT)
    if ('user' not in self.options):
        if DEFAULT_USER:
            self.options['user'] = DEFAULT_USER
        else:
            msg = 'Connection option "user" is required'
            self._logger.error(msg)
            raise KeyError(msg)
    self.options.setdefault('database', self.options['user'])
    self.options.setdefault('password', DEFAULT_PASSWORD)
    self.options.setdefault('autocommit', DEFAULT_AUTOCOMMIT)
    self.options.setdefault('session_label', _generate_session_label())
    self.options.setdefault('backup_server_node', DEFAULT_BACKUP_SERVER_NODE)
    self.options.setdefault('kerberos_service_name', DEFAULT_KRB_SERVICE_NAME)
    self.options.setdefault('kerberos_host_name', self.options['host'])
    self.address_list = _AddressList(self.options['host'], self.options['port'], self.options['backup_server_node'], self._logger)
    self.options.setdefault('unicode_error', None)
    self._cursor = Cursor(self, self._logger, cursor_type=None, unicode_error=self.options['unicode_error'])
    self.options.setdefault('use_prepared_statements', False)
    self._logger.debug('Connection prepared statements is {}'.format(('enabled' if self.options['use_prepared_statements'] else 'disabled')))
    self.options.setdefault('disable_copy_local', False)
    self._logger.debug('COPY LOCAL operation is {}'.format(('disabled' if self.options['disable_copy_local'] else 'enabled')))
    self._logger.info('Connecting as user "{}" to database "{}" on host "{}" with port {}'.format(self.options['user'], self.options['database'], self.options['host'], self.options['port']))
    self.startup_connection()
    if self.options['autocommit']:
        self.autocommit = True
    self._logger.info('Connection is ready')