Skip to content

Commit 03516c3

Browse files
committed
👷 add --mysql-ssl-{cert,key,ca} options
1 parent 9af779f commit 03516c3

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ Options:
6868
-W, --without-data Do not transfer table data, DDL only.
6969
-h, --mysql-host TEXT MySQL host. Defaults to localhost.
7070
-P, --mysql-port INTEGER MySQL port. Defaults to 3306.
71+
--mysql-ssl-cert PATH Path to SSL certificate file.
72+
--mysql-ssl-key PATH Path to SSL key file.
73+
--mysql-ssl-ca PATH Path to SSL CA certificate file.
7174
-S, --skip-ssl Disable MySQL connection encryption.
7275
-c, --chunk INTEGER Chunk reading/writing SQL records
7376
-l, --log-file PATH Log file

docs/README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Connection Options
4343

4444
- ``-h, --mysql-host TEXT``: MySQL host. Defaults to localhost.
4545
- ``-P, --mysql-port INTEGER``: MySQL port. Defaults to 3306.
46+
- ``--mysql-ssl-cert PATH``: Path to SSL certificate file.
47+
- ``--mysql-ssl-key PATH``: Path to SSL key file.
48+
- ``--mysql-ssl-ca PATH``: Path to SSL CA certificate file.
4649
- ``-S, --skip-ssl``: Disable MySQL connection encryption.
4750

4851
Other Options

src/mysql_to_sqlite3/cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
)
101101
@click.option("-h", "--mysql-host", default="localhost", help="MySQL host. Defaults to localhost.")
102102
@click.option("-P", "--mysql-port", type=int, default=3306, help="MySQL port. Defaults to 3306.")
103+
@click.option("--mysql-ssl-cert", type=click.Path(), help="Path to SSL certificate file.")
104+
@click.option("--mysql-ssl-key", type=click.Path(), help="Path to SSL key file.")
105+
@click.option("--mysql-ssl-ca", type=click.Path(), help="Path to SSL CA certificate file.")
103106
@click.option("-S", "--skip-ssl", is_flag=True, help="Disable MySQL connection encryption.")
104107
@click.option(
105108
"-c",
@@ -142,6 +145,9 @@ def cli(
142145
without_data: bool,
143146
mysql_host: str,
144147
mysql_port: int,
148+
mysql_ssl_cert: t.Optional[str],
149+
mysql_ssl_key: t.Optional[str],
150+
mysql_ssl_ca: t.Optional[str],
145151
skip_ssl: bool,
146152
chunk: int,
147153
log_file: t.Union[str, "os.PathLike[t.Any]"],
@@ -171,6 +177,9 @@ def cli(
171177
without_data=without_data,
172178
mysql_host=mysql_host,
173179
mysql_port=mysql_port,
180+
mysql_ssl_cert=mysql_ssl_cert,
181+
mysql_ssl_key=mysql_ssl_key,
182+
mysql_ssl_ca=mysql_ssl_ca,
174183
mysql_ssl_disabled=skip_ssl,
175184
chunk=chunk,
176185
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
@@ -88,6 +88,12 @@ def __init__(self, **kwargs: tx.Unpack[MySQLtoSQLiteParams]) -> None:
8888

8989
self._without_data = kwargs.get("without_data") or False
9090

91+
self._mysql_ssl_ca = kwargs.get("mysql_ssl_ca") or None
92+
93+
self._mysql_ssl_cert = kwargs.get("mysql_ssl_cert") or None
94+
95+
self._mysql_ssl_key = kwargs.get("mysql_ssl_key") or None
96+
9197
self._mysql_ssl_disabled = kwargs.get("mysql_ssl_disabled") or False
9298

9399
self._current_chunk_number = 0
@@ -123,6 +129,9 @@ def __init__(self, **kwargs: tx.Unpack[MySQLtoSQLiteParams]) -> None:
123129
password=self._mysql_password,
124130
host=self._mysql_host,
125131
port=self._mysql_port,
132+
ssl_ca=self._mysql_ssl_ca,
133+
ssl_cert=self._mysql_ssl_cert,
134+
ssl_key=self._mysql_ssl_key,
126135
ssl_disabled=self._mysql_ssl_disabled,
127136
)
128137
if isinstance(_mysql_connection, MySQLConnectionAbstract):

0 commit comments

Comments
 (0)