15
15
import typing_extensions as tx
16
16
from mysql .connector import errorcode
17
17
from mysql .connector .abstracts import MySQLConnectionAbstract
18
- from mysql .connector .types import ToPythonOutputTypes
18
+ from mysql .connector .types import RowItemType
19
19
from tqdm import tqdm , trange
20
20
21
21
from mysql_to_sqlite3 .mysql_utils import CHARSET_INTRODUCERS
@@ -252,9 +252,9 @@ def _translate_type_from_mysql_to_sqlite(
252
252
@classmethod
253
253
def _translate_default_from_mysql_to_sqlite (
254
254
cls ,
255
- column_default : ToPythonOutputTypes = None ,
255
+ column_default : RowItemType = None ,
256
256
column_type : t .Optional [str ] = None ,
257
- column_extra : ToPythonOutputTypes = None ,
257
+ column_extra : RowItemType = None ,
258
258
) -> str :
259
259
is_binary : bool
260
260
is_hex : bool
@@ -405,7 +405,7 @@ def _build_create_table_sql(self, table_name: str) -> str:
405
405
""" ,
406
406
(self ._mysql_database , table_name ),
407
407
)
408
- mysql_indices : t .Sequence [t .Optional [t .Dict [str , ToPythonOutputTypes ]]] = self ._mysql_cur_dict .fetchall ()
408
+ mysql_indices : t .Sequence [t .Optional [t .Dict [str , RowItemType ]]] = self ._mysql_cur_dict .fetchall ()
409
409
for index in mysql_indices :
410
410
if index is not None :
411
411
index_name : str
@@ -426,7 +426,7 @@ def _build_create_table_sql(self, table_name: str) -> str:
426
426
""" ,
427
427
(self ._mysql_database , index_name ),
428
428
)
429
- collision : t .Optional [t .Dict [str , ToPythonOutputTypes ]] = self ._mysql_cur_dict .fetchone ()
429
+ collision : t .Optional [t .Dict [str , RowItemType ]] = self ._mysql_cur_dict .fetchone ()
430
430
table_collisions : int = 0
431
431
if collision is not None :
432
432
table_collisions = int (collision ["count" ]) # type: ignore[arg-type]
@@ -456,7 +456,7 @@ def _build_create_table_sql(self, table_name: str) -> str:
456
456
sql = sql .rstrip (", " )
457
457
458
458
if not self ._without_foreign_keys :
459
- server_version : t .Tuple [int , ...] = self ._mysql .get_server_version ()
459
+ server_version : t .Optional [ t . Tuple [int , ...] ] = self ._mysql .get_server_version ()
460
460
self ._mysql_cur_dict .execute (
461
461
"""
462
462
SELECT k.COLUMN_NAME AS `column`,
@@ -481,7 +481,9 @@ def _build_create_table_sql(self, table_name: str) -> str:
481
481
c.UPDATE_RULE,
482
482
c.DELETE_RULE
483
483
""" .format (
484
- JOIN = "JOIN" if (server_version [0 ] == 8 and server_version [2 ] > 19 ) else "LEFT JOIN"
484
+ JOIN = "JOIN"
485
+ if (server_version is not None and server_version [0 ] == 8 and server_version [2 ] > 19 )
486
+ else "LEFT JOIN"
485
487
),
486
488
(self ._mysql_database , table_name , "FOREIGN KEY" ),
487
489
)
@@ -602,7 +604,7 @@ def transfer(self) -> None:
602
604
),
603
605
specific_tables ,
604
606
)
605
- tables : t .Iterable [ToPythonOutputTypes ] = (row [0 ] for row in self ._mysql_cur_prepared .fetchall ())
607
+ tables : t .Iterable [RowItemType ] = (row [0 ] for row in self ._mysql_cur_prepared .fetchall ())
606
608
else :
607
609
# transfer all tables
608
610
self ._mysql_cur .execute (
@@ -646,7 +648,7 @@ def transfer(self) -> None:
646
648
# get all rows
647
649
self ._mysql_cur_dict .execute (f"SELECT COUNT(*) AS `total_records` FROM `{ table_name } `" )
648
650
649
- total_records : t .Optional [t .Dict [str , ToPythonOutputTypes ]] = self ._mysql_cur_dict .fetchone ()
651
+ total_records : t .Optional [t .Dict [str , RowItemType ]] = self ._mysql_cur_dict .fetchone ()
650
652
if total_records is not None :
651
653
total_records_count : int = int (total_records ["total_records" ]) # type: ignore[arg-type]
652
654
else :
0 commit comments