Skip to content

Commit 7f626c8

Browse files
committed
👷 add --mysql-ssl-{cert,key,ca} options
1 parent 75bca3f commit 7f626c8

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ Options:
6565
--mysql-charset TEXT MySQL database and table character set
6666
[default: utf8mb4]
6767
--mysql-collation TEXT MySQL database and table collation
68+
--mysql-ssl-cert PATH Path to SSL certificate file.
69+
--mysql-ssl-key PATH Path to SSL key file.
70+
--mysql-ssl-ca PATH Path to SSL CA certificate file.
6871
-S, --skip-ssl Disable MySQL connection encryption.
6972
-c, --chunk INTEGER Chunk reading/writing SQL records
7073
-l, --log-file PATH Log file

docs/README.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ Connection Options
4545
- ``-h, --mysql-host TEXT``: MySQL host. Defaults to localhost.
4646
- ``-P, --mysql-port INTEGER``: MySQL port. Defaults to 3306.
4747
- ``--mysql-charset TEXT``: MySQL database and table character set. The default is utf8mb4.
48-
- ``--mysql-collation TEXT``: MySQL database and table collation
48+
- ``--mysql-collation TEXT``: MySQL database and table collation.
49+
- ``--mysql-ssl-cert PATH``: Path to SSL certificate file.
50+
- ``--mysql-ssl-key PATH``: Path to SSL key file.
51+
- ``--mysql-ssl-ca PATH``: Path to SSL CA certificate file.
4952
- ``-S, --skip-ssl``: Disable MySQL connection encryption.
5053

5154
Other Options

src/mysql_to_sqlite3/cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
default=None,
127127
help="MySQL database and table collation",
128128
)
129+
@click.option("--mysql-ssl-cert", type=click.Path(), help="Path to SSL certificate file.")
130+
@click.option("--mysql-ssl-key", type=click.Path(), help="Path to SSL key file.")
131+
@click.option("--mysql-ssl-ca", type=click.Path(), help="Path to SSL CA certificate file.")
129132
@click.option("-S", "--skip-ssl", is_flag=True, help="Disable MySQL connection encryption.")
130133
@click.option(
131134
"-c",
@@ -171,6 +174,9 @@ def cli(
171174
mysql_port: int,
172175
mysql_charset: str,
173176
mysql_collation: str,
177+
mysql_ssl_cert: t.Optional[str],
178+
mysql_ssl_key: t.Optional[str],
179+
mysql_ssl_ca: t.Optional[str],
174180
skip_ssl: bool,
175181
chunk: int,
176182
log_file: t.Union[str, "os.PathLike[t.Any]"],
@@ -219,6 +225,9 @@ def cli(
219225
mysql_port=mysql_port,
220226
mysql_charset=mysql_charset,
221227
mysql_collation=mysql_collation,
228+
mysql_ssl_cert=mysql_ssl_cert,
229+
mysql_ssl_key=mysql_ssl_key,
230+
mysql_ssl_ca=mysql_ssl_ca,
222231
mysql_ssl_disabled=skip_ssl,
223232
chunk=chunk,
224233
json_as_text=json_as_text,

src/mysql_to_sqlite3/transporter.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ def __init__(self, **kwargs: tx.Unpack[MySQLtoSQLiteParams]) -> None:
100100
if self._without_tables and self._without_data:
101101
raise ValueError("Unable to continue without transferring data or creating tables!")
102102

103+
self._mysql_ssl_ca = kwargs.get("mysql_ssl_ca") or None
104+
105+
self._mysql_ssl_cert = kwargs.get("mysql_ssl_cert") or None
106+
107+
self._mysql_ssl_key = kwargs.get("mysql_ssl_key") or None
108+
103109
self._mysql_ssl_disabled = bool(kwargs.get("mysql_ssl_disabled", False))
104110

105111
self._current_chunk_number = 0
@@ -135,6 +141,9 @@ def __init__(self, **kwargs: tx.Unpack[MySQLtoSQLiteParams]) -> None:
135141
password=self._mysql_password,
136142
host=self._mysql_host,
137143
port=self._mysql_port,
144+
ssl_ca=self._mysql_ssl_ca,
145+
ssl_cert=self._mysql_ssl_cert,
146+
ssl_key=self._mysql_ssl_key,
138147
ssl_disabled=self._mysql_ssl_disabled,
139148
charset=self._mysql_charset,
140149
collation=self._mysql_collation,

0 commit comments

Comments
 (0)