Add option to change type of single column, adjust README
This commit is contained in:
parent
2673c92b4e
commit
d243bdf77c
@ -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`
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user