1515import typing_extensions as tx
1616from mysql .connector import errorcode
1717from mysql .connector .abstracts import MySQLConnectionAbstract
18- from mysql .connector .types import ToPythonOutputTypes
18+ from mysql .connector .types import RowItemType
1919from tqdm import tqdm , trange
2020
2121from mysql_to_sqlite3 .mysql_utils import CHARSET_INTRODUCERS
@@ -252,9 +252,9 @@ def _translate_type_from_mysql_to_sqlite(
252252 @classmethod
253253 def _translate_default_from_mysql_to_sqlite (
254254 cls ,
255- column_default : ToPythonOutputTypes = None ,
255+ column_default : RowItemType = None ,
256256 column_type : t .Optional [str ] = None ,
257- column_extra : ToPythonOutputTypes = None ,
257+ column_extra : RowItemType = None ,
258258 ) -> str :
259259 is_binary : bool
260260 is_hex : bool
@@ -405,7 +405,7 @@ def _build_create_table_sql(self, table_name: str) -> str:
405405 """ ,
406406 (self ._mysql_database , table_name ),
407407 )
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 ()
409409 for index in mysql_indices :
410410 if index is not None :
411411 index_name : str
@@ -426,7 +426,7 @@ def _build_create_table_sql(self, table_name: str) -> str:
426426 """ ,
427427 (self ._mysql_database , index_name ),
428428 )
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 ()
430430 table_collisions : int = 0
431431 if collision is not None :
432432 table_collisions = int (collision ["count" ]) # type: ignore[arg-type]
@@ -456,7 +456,7 @@ def _build_create_table_sql(self, table_name: str) -> str:
456456 sql = sql .rstrip (", " )
457457
458458 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 ()
460460 self ._mysql_cur_dict .execute (
461461 """
462462 SELECT k.COLUMN_NAME AS `column`,
@@ -481,7 +481,9 @@ def _build_create_table_sql(self, table_name: str) -> str:
481481 c.UPDATE_RULE,
482482 c.DELETE_RULE
483483 """ .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"
485487 ),
486488 (self ._mysql_database , table_name , "FOREIGN KEY" ),
487489 )
@@ -602,7 +604,7 @@ def transfer(self) -> None:
602604 ),
603605 specific_tables ,
604606 )
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 ())
606608 else :
607609 # transfer all tables
608610 self ._mysql_cur .execute (
@@ -646,7 +648,7 @@ def transfer(self) -> None:
646648 # get all rows
647649 self ._mysql_cur_dict .execute (f"SELECT COUNT(*) AS `total_records` FROM `{ table_name } `" )
648650
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 ()
650652 if total_records is not None :
651653 total_records_count : int = int (total_records ["total_records" ]) # type: ignore[arg-type]
652654 else :
0 commit comments