Initializes the sql tools client. Input and output streams for JsonRpcClient are taken as optional params, Else a SqlToolsService process is started and its stdin and stdout is used.
(self, input_stream=None, output_stream=None, enable_logging=False)
| 22 | QUERY_SUBSET_REQUEST = u'query_subset_request' |
| 23 | |
| 24 | def __init__(self, input_stream=None, output_stream=None, enable_logging=False): |
| 25 | """ |
| 26 | Initializes the sql tools client. |
| 27 | Input and output streams for JsonRpcClient are taken as optional params, |
| 28 | Else a SqlToolsService process is started and its stdin and stdout is used. |
| 29 | """ |
| 30 | self.current_id = uuid.uuid4().int |
| 31 | self.tools_service_process = None |
| 32 | |
| 33 | sqltoolsservice_args = [mssqltoolsservice.get_executable_path()] |
| 34 | |
| 35 | if enable_logging: |
| 36 | sqltoolsservice_args.append('--enable-logging') |
| 37 | sqltoolsservice_args.append('--log-dir') |
| 38 | sqltoolsservice_args.append(config_location()) |
| 39 | |
| 40 | if input_stream and output_stream: |
| 41 | self.json_rpc_client = json_rpc_client.JsonRpcClient( |
| 42 | input_stream, output_stream) |
| 43 | else: |
| 44 | self.tools_service_process = subprocess.Popen( |
| 45 | sqltoolsservice_args, |
| 46 | bufsize=0, |
| 47 | stdin=subprocess.PIPE, |
| 48 | stdout=subprocess.PIPE) |
| 49 | |
| 50 | self.json_rpc_client = json_rpc_client.JsonRpcClient( |
| 51 | self.tools_service_process.stdin, |
| 52 | io.open( |
| 53 | self.tools_service_process.stdout.fileno(), |
| 54 | u'rb', |
| 55 | buffering=0, |
| 56 | closefd=False)) |
| 57 | |
| 58 | logger.info(u'SqlToolsService process id: %s', self.tools_service_process.pid) |
| 59 | |
| 60 | self.json_rpc_client.start() |
| 61 | logger.info(u'Sql Tools Client Initialized') |
| 62 | |
| 63 | def create_request(self, request_type, parameters, owner_uri): |
| 64 | """ |
nothing calls this directly
no test coverage detected