Skip to content

Commit 91cbf58

Browse files
committed
merge master
2 parents a5dbf4c + bfe3524 commit 91cbf58

7 files changed

+25
-8
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ __pycache__/
88

99
# Distribution / packaging
1010
.Python
11-
env/
11+
env*/
1212
build/
1313
develop-eggs/
1414
dist/
@@ -83,7 +83,7 @@ celerybeat-schedule
8383
.env
8484

8585
# sqltoolsservice binaries
86-
/pgcli/mssqltoolsservice/bin/*
86+
/mssqlcli/mssqltoolsservice/bin/*
8787

8888
# virtualenv
8989
.venv

mssqlcli/main.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ def set_default_pager(self, config):
124124
def __init__(self, force_passwd_prompt=False,
125125
mssqlclirc_file=None, row_limit=None,
126126
single_connection=False, less_chatty=None,
127-
auto_vertical_output=False, sql_tools_client=None, integrated_auth=False):
127+
auto_vertical_output=False, sql_tools_client=None,
128+
integrated_auth=False, enable_sqltoolsservice_logging=False):
128129

129130
self.force_passwd_prompt = force_passwd_prompt
130131

@@ -193,7 +194,8 @@ def __init__(self, force_passwd_prompt=False,
193194
self.cli = None
194195

195196
# mssql-cli
196-
self.sqltoolsclient = sql_tools_client if sql_tools_client else SqlToolsClient()
197+
self.sqltoolsclient = sql_tools_client if sql_tools_client else SqlToolsClient(
198+
enable_logging=enable_sqltoolsservice_logging)
197199
self.mssqlcliclient_query_execution = None
198200
self.integrated_auth = integrated_auth
199201

@@ -695,9 +697,14 @@ def get_last_query(self):
695697
'detection and connection to currently active server.')
696698
@click.option('-a', '--packet-size', default=0, type=int,
697699
help='Size in bytes of the network packets used to communicate with SQL Server.')
700+
@click.option('-A', '--dac-connection', is_flag=True, default=False,
701+
help='Connect to SQL Server using the dedicated administrator connection.')
702+
@click.option('--enable-sqltoolsservice-logging', is_flag=True,
703+
default=False,
704+
help='Enables diagnostic logging for the SqlToolsService.')
698705
def cli(username, server, prompt_passwd, database, version, mssqlclirc, row_limit, less_chatty, auto_vertical_output,
699706
integrated_auth, encrypt, trust_server_certificate, connect_timeout, application_intent, multi_subnet_failover,
700-
packet_size):
707+
packet_size, enable_sqltoolsservice_logging, dac_connection):
701708

702709
if version:
703710
print('Version:', __version__)
@@ -712,9 +719,12 @@ def cli(username, server, prompt_passwd, database, version, mssqlclirc, row_limi
712719
integrated_auth = False
713720
print (u'Integrated authentication not supported on this platform')
714721

722+
if dac_connection and server and not server.lower().startswith("admin:"):
723+
server = "admin:" + server
724+
715725
mssqlcli = MssqlCli(prompt_passwd, row_limit=row_limit, single_connection=False,
716726
mssqlclirc_file=mssqlclirc, less_chatty=less_chatty, auto_vertical_output=auto_vertical_output,
717-
integrated_auth=integrated_auth)
727+
integrated_auth=integrated_auth, enable_sqltoolsservice_logging=enable_sqltoolsservice_logging)
718728

719729
mssqlcli.connect(database, server, username, port='', encrypt=encrypt,
720730
trust_server_certificate=trust_server_certificate, connection_timeout=connect_timeout,

mssqlcli/sqltoolsclient.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
import mssqlcli.jsonrpc.jsonrpcclient as json_rpc_client
1515
import mssqlcli.jsonrpc.contracts.connectionservice as connection
1616
import mssqlcli.jsonrpc.contracts.queryexecutestringservice as query
17+
from .config import config_location
1718

1819
logger = logging.getLogger(u'mssqlcli.sqltoolsclient')
19-
sqltoolsservice_args = [mssqltoolsservice.get_executable_path()]
2020

2121

2222
class SqlToolsClient(object):
2323
"""
2424
Create sql tools service requests.
2525
"""
2626

27-
def __init__(self, input_stream=None, output_stream=None):
27+
def __init__(self, input_stream=None, output_stream=None, enable_logging=False):
2828
"""
2929
Initializes the sql tools client.
3030
Input and output streams for JsonRpcClient are taken as optional params,
@@ -33,6 +33,13 @@ def __init__(self, input_stream=None, output_stream=None):
3333
self.current_id = uuid.uuid4().int
3434
self.tools_service_process = None
3535

36+
sqltoolsservice_args = [mssqltoolsservice.get_executable_path()]
37+
38+
if enable_logging:
39+
sqltoolsservice_args.append('--enable-logging')
40+
sqltoolsservice_args.append('--log-dir')
41+
sqltoolsservice_args.append(config_location())
42+
3643
if input_stream and output_stream:
3744
self.json_rpc_client = json_rpc_client.JsonRpcClient(
3845
input_stream, output_stream)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)