From b000a48daf78ac2a4c09adfc7bf44fd919764bd6 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 10 Dec 2023 15:03:40 +0300 Subject: [PATCH] Fix(Py3): `sqlparse` lost module `compat` --- scripts/mysql2sql | 6 +++++- sqlconvert/process_tokens.py | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/mysql2sql b/scripts/mysql2sql index cacbafa..e859f2a 100755 --- a/scripts/mysql2sql +++ b/scripts/mysql2sql @@ -6,7 +6,6 @@ from io import open import os import sys -from sqlparse.compat import text_type from sqlconvert.print_tokens import print_tokens from sqlconvert.process_mysql import is_directive_statement, process_statement from sqlconvert.process_tokens import is_newline_statement, StatementGrouper @@ -14,6 +13,11 @@ from sqlconvert.process_tokens import is_newline_statement, StatementGrouper from m_lib.defenc import default_encoding from m_lib.pbar.tty_pbar import ttyProgressBar +try: + text_type = unicode +except NameError: + text_type = str + def get_fsize(fp): try: diff --git a/sqlconvert/process_tokens.py b/sqlconvert/process_tokens.py index 414c5ca..886f36d 100644 --- a/sqlconvert/process_tokens.py +++ b/sqlconvert/process_tokens.py @@ -2,9 +2,13 @@ from sqlparse.sql import Comment from sqlobject.converters import sqlrepr from sqlparse import parse -from sqlparse.compat import PY3 from sqlparse import tokens as T +try: + xrange +except NameError: + xrange = range + def find_error(token_list): """Find an error""" @@ -36,10 +40,6 @@ def escape_strings(token_list, dbname): token.normalized = token.value = value -if PY3: - xrange = range - - class StatementGrouper(object): """Collect lines and reparse until the last statement is complete""" -- 2.39.5