diff --git a/README.md b/README.md index de29d3b..3171feb 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ If an error occurs during the conversion of a table or column, an output with th ## Usage ``` -python convert.py [-h] [-v] -H HOST -P PORT -u USER -p PASSWORD -d DATABASE +python convert.py [-h] [-v] [-s] -H HOST -P PORT -u USER -p PASSWORD -d DATABASE ``` Required arguments: - `-H/--host HOST` @@ -27,4 +27,4 @@ Required arguments: Optional arguments: - `-h/--help` - `-v/--verbose` - +- `-s/--statistics` \ No newline at end of file diff --git a/convert/utf8mb4converter.py b/convert/utf8mb4converter.py index 8f51a5e..7e81e0d 100644 --- a/convert/utf8mb4converter.py +++ b/convert/utf8mb4converter.py @@ -253,6 +253,7 @@ class UTF8MB4Converter: self, column: dict, table: str, + newtype: str = None, charset: str = DEFAULT_CHARSET, collation: str = DEFAULT_COLLATION ) -> None: @@ -264,6 +265,10 @@ class UTF8MB4Converter: - a dict containig information about the column to be altered - table (str) - the table housing the column + - newtype (str) + - enter a new type if it should be changed + - if no type is entered, the type is kept + - default value: None - charset (str) - target character set - default value: utf8mb4 @@ -287,7 +292,7 @@ class UTF8MB4Converter: query = " ".join(( f"ALTER TABLE {table} CHANGE {col} {col}", - f"{column['ctype']} CHARACTER SET {charset} COLLATE {collation}", + f"{newtype or column['ctype']} CHARACTER SET {charset} COLLATE {collation}", "NULL" if column["nullable"] == "YES" else f"NOT NULL DEFAULT {column['dvalue']}" )) try: