File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22from __future__ import print_function
33
44import getpass
5+ import io
56import os
67import sys
78from builtins import input
89import click
9-
10+ import six
1011from mssqlcli .config import config_location
1112from mssqlcli .__init__ import __version__
1213from mssqlcli .mssqlclioptionsparser import create_parser
@@ -58,9 +59,14 @@ def run_cli_with(options):
5859 if options .input_file :
5960 # get query text from input file
6061 try :
61- with open (options .input_file , 'r' ) as f :
62- text = f .read ()
63- except FileNotFoundError as e :
62+ if six .PY2 :
63+ with io .open (options .input_file , 'r' , encoding = 'utf-8' ) as f :
64+ # utf-8 encoding must be called again for windows
65+ text = f .read ().encode ('utf-8' )
66+ else :
67+ with open (options .input_file , 'r' , encoding = 'utf-8' ) as f :
68+ text = f .read ()
69+ except OSError as e :
6470 click .secho (str (e ), err = True , fg = 'red' )
6571 sys .exit (1 )
6672 mssqlcli .execute_query (text )
You can’t perform that action at this time.
0 commit comments