Skip to content

Commit 96635fb

Browse files
committed
🚑 Fix #46
1 parent 463bf68 commit 96635fb

File tree

3 files changed

+11
-54
lines changed

3 files changed

+11
-54
lines changed

requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ docker>=4.0.2
44
factory-boy
55
Faker>=4.1.0 ; python_version>="3.0"
66
mysql-connector-python>=8.0.18,<8.0.24 ; python_version<"3.6"
7-
mysql-connector-python>=8.0.18 ; python_version>="3.6"
7+
mysql-connector-python>=8.0.18,<8.0.30 ; python_version>="3.6"
88
PyMySQL>=0.9.3
99
PyMySQL[rsa]
1010
pytest>=4.6.5

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"Click>=7.0,<8.0.0 ; python_version<'3.6'",
1212
"Click>=7.0 ; python_version>='3.6'",
1313
"mysql-connector-python>=8.0.18,<8.0.24 ; python_version<'3.6'",
14-
"mysql-connector-python>=8.0.18 ; python_version>='3.6'",
14+
"mysql-connector-python>=8.0.18,<8.0.30 ; python_version>='3.6'",
1515
"pytimeparse>=1.1.8",
1616
"six>=1.12.0",
1717
"simplejson>=3.16.0",

sqlite3_to_mysql/transporter.py

Lines changed: 9 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -124,39 +124,15 @@ def __init__(self, **kwargs):
124124

125125
self._mysql_charset = kwargs.get("mysql_charset") or "utf8mb4"
126126

127-
try:
128-
self._mysql_collation = (
129-
kwargs.get("mysql_collation")
130-
or CharacterSet.get_default_collation(self._mysql_charset.lower())[0]
131-
)
132-
if (
133-
not kwargs.get("mysql_collation")
134-
and self._mysql_collation == "utf8mb4_0900_ai_ci"
135-
):
136-
self._mysql_collation = "utf8mb4_general_ci"
137-
except mysql.connector.errors.ProgrammingError:
138-
if (
139-
self.MYSQL_CONNECTOR_VERSION.major >= 8
140-
and self.MYSQL_CONNECTOR_VERSION.micro >= 30
141-
):
142-
# Looks like we're dealing with mysql-connector-python >= 8.0.30 and MySQL 5.7 or MariaDB
143-
# https://github.com/techouse/sqlite3-to-mysql/issues/46
144-
# https://dev.mysql.com/doc/relnotes/connector-python/en/news-8-0-30.html
145-
self._logger.warning(
146-
"Looks like you're using mysql-connector-python >= 8.0.30 with an older version of MySQL."
147-
)
148-
CharacterSet.set_mysql_version((5, 7))
149-
self._mysql_collation = (
150-
kwargs.get("mysql_collation")
151-
or CharacterSet.get_default_collation(self._mysql_charset.lower())[
152-
0
153-
]
154-
)
155-
if (
156-
not kwargs.get("mysql_collation")
157-
and self._mysql_collation == "utf8mb4_0900_ai_ci"
158-
):
159-
self._mysql_collation = "utf8mb4_general_ci"
127+
self._mysql_collation = (
128+
kwargs.get("mysql_collation")
129+
or CharacterSet.get_default_collation(self._mysql_charset.lower())[0]
130+
)
131+
if (
132+
not kwargs.get("mysql_collation")
133+
and self._mysql_collation == "utf8mb4_0900_ai_ci"
134+
):
135+
self._mysql_collation = "utf8mb4_general_ci"
160136

161137
self.ignore_duplicate_keys = kwargs.get("ignore_duplicate_keys") or False
162138

@@ -181,9 +157,6 @@ def __init__(self, **kwargs):
181157

182158
self._sqlite_cur = self._sqlite.cursor()
183159

184-
self._connect()
185-
186-
def _connect(self, retried_mysql_57=False):
187160
try:
188161
self._mysql = mysql.connector.connect(
189162
user=self._mysql_user,
@@ -217,22 +190,6 @@ def _connect(self, retried_mysql_57=False):
217190
raise ValueError(
218191
"Your MySQL version does not support InnoDB FULLTEXT indexes!"
219192
)
220-
except mysql.connector.errors.ProgrammingError as err:
221-
if not retried_mysql_57:
222-
if (
223-
self.MYSQL_CONNECTOR_VERSION.major >= 8
224-
and self.MYSQL_CONNECTOR_VERSION.micro >= 30
225-
):
226-
# Looks like we're dealing with mysql-connector-python >= 8.0.30 and MySQL 5.7 or MariaDB
227-
# https://github.com/techouse/sqlite3-to-mysql/issues/46
228-
# https://dev.mysql.com/doc/relnotes/connector-python/en/news-8-0-30.html
229-
self._logger.warning(
230-
"Looks like you're using mysql-connector-python >= 8.0.30 with an older version of MySQL."
231-
)
232-
CharacterSet.set_mysql_version((5, 7))
233-
return self._connect(retried_mysql_57=True)
234-
self._logger.error(err)
235-
raise
236193
except mysql.connector.Error as err:
237194
self._logger.error(err)
238195
raise

0 commit comments

Comments
 (0)