@@ -49,6 +49,7 @@ class SQLite3toMySQL(SQLite3toMySQLAttributes):
49
49
50
50
COLUMN_PATTERN : t .Pattern [str ] = re .compile (r"^[^(]+" )
51
51
COLUMN_LENGTH_PATTERN : t .Pattern [str ] = re .compile (r"\(\d+\)" )
52
+ COLUMN_PRECISION_AND_SCALE_PATTERN : t .Pattern [str ] = re .compile (r"\(\d+,\d+\)" )
52
53
COLUMN_UNSIGNED_PATTERN : t .Pattern [str ] = re .compile (r"\bUNSIGNED\b" , re .IGNORECASE )
53
54
54
55
MYSQL_CONNECTOR_VERSION : version .Version = version .parse (mysql_connector_version_string )
@@ -291,6 +292,8 @@ def _translate_type_from_sqlite_to_mysql(self, column_type: str) -> str:
291
292
if data_type .startswith (("BIGINT" , "INT8" )):
292
293
return f"BIGINT{ self ._column_type_length (column_type )} { ' UNSIGNED' if unsigned else '' } "
293
294
if data_type .startswith (("INT64" , "NUMERIC" )):
295
+ if data_type == "NUMERIC" and self ._column_type_precision_and_scale (full_column_type ) != "" :
296
+ return f"DECIMAL{ self ._column_type_precision_and_scale (column_type )} { ' UNSIGNED' if unsigned else '' } "
294
297
return f"BIGINT{ self ._column_type_length (column_type , 19 )} { ' UNSIGNED' if unsigned else '' } "
295
298
if data_type .startswith (("INTEGER" , "INT" )):
296
299
length = self ._column_type_length (column_type )
@@ -320,6 +323,13 @@ def _column_type_length(cls, column_type: str, default: t.Optional[t.Union[str,
320
323
return f"({ default } )"
321
324
return ""
322
325
326
+ @classmethod
327
+ def _column_type_precision_and_scale (cls , column_type : str ) -> str :
328
+ suffix : t .Optional [t .Match [str ]] = cls .COLUMN_PRECISION_AND_SCALE_PATTERN .search (column_type )
329
+ if suffix :
330
+ return suffix .group (0 )
331
+ return ""
332
+
323
333
def _create_table (self , table_name : str , transfer_rowid : bool = False ) -> None :
324
334
primary_keys : t .List [t .Dict [str , str ]] = []
325
335
0 commit comments