]> git.phdru.name Git - sqlconvert.git/blobdiff - scripts/mysql2sql
Refactor: Rename internal `statement` to `_statement`
[sqlconvert.git] / scripts / mysql2sql
index e4f2e4bbf9fa0eb9c84c1759fcd41cc79b13cfb0..cacbafa13444ea26898b5dcca80b065784fad485 100755 (executable)
@@ -31,8 +31,12 @@ def main(infile, encoding, outfile, output_encoding, use_pbar, quoting_style):
         if size is None:
             use_pbar = False
 
-    print("Converting: ", end='', file=sys.stderr)
-    sys.stderr.flush()
+    if use_pbar:
+        print("Converting", end='', file=sys.stderr)
+        if infile.name != '<stdin>':
+            print(' ' + infile.name, end='', file=sys.stderr)
+        print(": ", end='', file=sys.stderr)
+        sys.stderr.flush()
 
     if use_pbar:
         pbar = ttyProgressBar(0, size-1)
@@ -56,8 +60,8 @@ def main(infile, encoding, outfile, output_encoding, use_pbar, quoting_style):
             got_directive = is_directive_statement(statement)
             if got_directive:
                 continue
-            for statement in process_statement(statement, quoting_style):
-                print_tokens(statement, outfile=outfile,
+            for _statement in process_statement(statement, quoting_style):
+                print_tokens(_statement, outfile=outfile,
                              encoding=output_encoding)
     tokens = grouper.close()
     if tokens:
@@ -66,7 +70,7 @@ def main(infile, encoding, outfile, output_encoding, use_pbar, quoting_style):
 
     if use_pbar:
         pbar.erase()
-    print("done.")
+        print("done.")
 
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(description='Convert MySQL to SQL')
@@ -133,6 +137,7 @@ if __name__ == '__main__':
 
     if outfile == '-':
         outfile = sys.stdout
+        args.no_pbar = True
     else:
         try:
             outfile = open(outfile, 'wt', encoding=output_encoding)