1- import sublime , os , tempfile , threading , signal , shlex , subprocess , sys
1+ import sublime , os , threading , signal , shlex , subprocess , sys
22
33sys .path .append (os .path .dirname (__file__ ))
44if sys .version_info >= (3 , 0 ):
@@ -259,18 +259,15 @@ def run(self):
259259 return
260260
261261 sublime .status_message (' ST: running SQL command' )
262- self .tmp = tempfile .NamedTemporaryFile (mode = 'w' , delete = False , suffix = '.sql' )
263- self .tmp .write (self .query )
264- self .tmp .close ()
265-
266262 self .args = map (str , self .args )
267263 si = None
268264 if os .name == 'nt' :
269265 si = subprocess .STARTUPINFO ()
270266 si .dwFlags |= subprocess .STARTF_USESHOWWINDOW
271- self .process = subprocess .Popen (self .args , stdout = subprocess .PIPE ,stderr = subprocess .PIPE , stdin = open (self .tmp .name ), env = os .environ .copy (), startupinfo = si )
272267
273- results , errors = self .process .communicate ()
268+ self .process = subprocess .Popen (self .args , stdout = subprocess .PIPE ,stderr = subprocess .PIPE , stdin = subprocess .PIPE , env = os .environ .copy (), startupinfo = si )
269+
270+ results , errors = self .process .communicate (input = self .query .encode ())
274271
275272 if errors :
276273 self .callback (errors .decode (self .encoding , 'replace' ).replace ('\r ' , '' ))
@@ -289,8 +286,6 @@ def stop(self):
289286 Log .debug ("Your command is taking too long to run. Process killed" )
290287 except Exception :
291288 pass
292- if self .tmp and os .path .exists (self .tmp .name ):
293- os .unlink (self .tmp .name )
294289
295290class Utils :
296291 @staticmethod
0 commit comments