@@ -57,18 +57,18 @@ def __init__(self, **kwargs: tx.Unpack[MySQLtoSQLiteParams]) -> None:
5757
5858 self ._mysql_password = str (kwargs .get ("mysql_password" )) or None
5959
60- self ._mysql_host = kwargs .get ("mysql_host" ) or "localhost"
60+ self ._mysql_host = kwargs .get ("mysql_host" , "localhost" ) or "localhost"
6161
62- self ._mysql_port = kwargs .get ("mysql_port" ) or 3306
62+ self ._mysql_port = kwargs .get ("mysql_port" , 3306 ) or 3306
6363
6464 self ._mysql_tables = kwargs .get ("mysql_tables" ) or tuple ()
6565
6666 self ._exclude_mysql_tables = kwargs .get ("exclude_mysql_tables" ) or tuple ()
6767
68- if len (self ._mysql_tables ) > 0 and len (self ._exclude_mysql_tables ) > 0 :
68+ if bool (self ._mysql_tables ) and bool (self ._exclude_mysql_tables ):
6969 raise ValueError ("mysql_tables and exclude_mysql_tables are mutually exclusive" )
7070
71- self ._limit_rows = kwargs .get ("limit_rows" ) or 0
71+ self ._limit_rows = kwargs .get ("limit_rows" , 0 ) or 0
7272
7373 if kwargs .get ("collation" ) is not None and str (kwargs .get ("collation" )).upper () in {
7474 CollatingSequences .BINARY ,
@@ -79,26 +79,30 @@ def __init__(self, **kwargs: tx.Unpack[MySQLtoSQLiteParams]) -> None:
7979 else :
8080 self ._collation = CollatingSequences .BINARY
8181
82- self ._prefix_indices = kwargs .get ("prefix_indices" ) or False
82+ self ._prefix_indices = kwargs .get ("prefix_indices" , False ) or False
8383
84- if len (self ._mysql_tables ) > 0 or len (self ._exclude_mysql_tables ) > 0 :
84+ if bool (self ._mysql_tables ) or bool (self ._exclude_mysql_tables ):
8585 self ._without_foreign_keys = True
8686 else :
87- self ._without_foreign_keys = kwargs .get ("without_foreign_keys" ) or False
87+ self ._without_foreign_keys = bool (kwargs .get ("without_foreign_keys" , False ))
88+
89+ self ._without_data = bool (kwargs .get ("without_data" , False ))
90+ self ._without_tables = bool (kwargs .get ("without_tables" , False ))
8891
89- self ._without_data = kwargs .get ("without_data" ) or False
92+ if self ._without_tables and self ._without_data :
93+ raise ValueError ("Unable to continue without transferring data or creating tables!" )
9094
91- self ._mysql_ssl_disabled = kwargs .get ("mysql_ssl_disabled" ) or False
95+ self ._mysql_ssl_disabled = bool ( kwargs .get ("mysql_ssl_disabled" , False ))
9296
9397 self ._current_chunk_number = 0
9498
9599 self ._chunk_size = kwargs .get ("chunk" ) or None
96100
97- self ._buffered = kwargs .get ("buffered" ) or False
101+ self ._buffered = bool ( kwargs .get ("buffered" , False ))
98102
99- self ._vacuum = kwargs .get ("vacuum" ) or False
103+ self ._vacuum = bool ( kwargs .get ("vacuum" , False ))
100104
101- self ._quiet = kwargs .get ("quiet" ) or False
105+ self ._quiet = bool ( kwargs .get ("quiet" , False ))
102106
103107 self ._logger = self ._setup_logger (log_file = kwargs .get ("log_file" ) or None , quiet = self ._quiet )
104108
@@ -113,7 +117,7 @@ def __init__(self, **kwargs: tx.Unpack[MySQLtoSQLiteParams]) -> None:
113117
114118 self ._sqlite_cur = self ._sqlite .cursor ()
115119
116- self ._json_as_text = kwargs .get ("json_as_text" ) or False
120+ self ._json_as_text = bool ( kwargs .get ("json_as_text" , False ))
117121
118122 self ._sqlite_json1_extension_enabled = not self ._json_as_text and self ._check_sqlite_json1_extension_enabled ()
119123
@@ -490,7 +494,7 @@ def _build_create_table_sql(self, table_name: str) -> str:
490494 sql += primary
491495 sql = sql .rstrip (", " )
492496
493- if not self ._without_foreign_keys :
497+ if not self ._without_tables and not self . _without_foreign_keys :
494498 server_version : t .Optional [t .Tuple [int , ...]] = self ._mysql .get_server_version ()
495499 self ._mysql_cur_dict .execute (
496500 """
@@ -662,16 +666,18 @@ def transfer(self) -> None:
662666 table_name = table_name .decode ()
663667
664668 self ._logger .info (
665- "%sTransferring table %s" ,
669+ "%s% sTransferring table %s" ,
666670 "[WITHOUT DATA] " if self ._without_data else "" ,
671+ "[ONLY DATA] " if self ._without_tables else "" ,
667672 table_name ,
668673 )
669674
670675 # reset the chunk
671676 self ._current_chunk_number = 0
672677
673- # create the table
674- self ._create_table (table_name ) # type: ignore[arg-type]
678+ if not self ._without_tables :
679+ # create the table
680+ self ._create_table (table_name ) # type: ignore[arg-type]
675681
676682 if not self ._without_data :
677683 # get the size of the data
0 commit comments