Skip to content

Commit

Permalink
👷 add --mysql-ssl-{cert,key,ca} options
Browse files Browse the repository at this point in the history
  • Loading branch information
frugan-dev committed Aug 6, 2024
1 parent 75bca3f commit 7f626c8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Options:
--mysql-charset TEXT MySQL database and table character set
[default: utf8mb4]
--mysql-collation TEXT MySQL database and table collation
--mysql-ssl-cert PATH Path to SSL certificate file.
--mysql-ssl-key PATH Path to SSL key file.
--mysql-ssl-ca PATH Path to SSL CA certificate file.
-S, --skip-ssl Disable MySQL connection encryption.
-c, --chunk INTEGER Chunk reading/writing SQL records
-l, --log-file PATH Log file
Expand Down
5 changes: 4 additions & 1 deletion docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ Connection Options
- ``-h, --mysql-host TEXT``: MySQL host. Defaults to localhost.
- ``-P, --mysql-port INTEGER``: MySQL port. Defaults to 3306.
- ``--mysql-charset TEXT``: MySQL database and table character set. The default is utf8mb4.
- ``--mysql-collation TEXT``: MySQL database and table collation
- ``--mysql-collation TEXT``: MySQL database and table collation.
- ``--mysql-ssl-cert PATH``: Path to SSL certificate file.
- ``--mysql-ssl-key PATH``: Path to SSL key file.
- ``--mysql-ssl-ca PATH``: Path to SSL CA certificate file.
- ``-S, --skip-ssl``: Disable MySQL connection encryption.

Other Options
Expand Down
9 changes: 9 additions & 0 deletions src/mysql_to_sqlite3/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
default=None,
help="MySQL database and table collation",
)
@click.option("--mysql-ssl-cert", type=click.Path(), help="Path to SSL certificate file.")
@click.option("--mysql-ssl-key", type=click.Path(), help="Path to SSL key file.")
@click.option("--mysql-ssl-ca", type=click.Path(), help="Path to SSL CA certificate file.")
@click.option("-S", "--skip-ssl", is_flag=True, help="Disable MySQL connection encryption.")
@click.option(
"-c",
Expand Down Expand Up @@ -171,6 +174,9 @@ def cli(
mysql_port: int,
mysql_charset: str,
mysql_collation: str,
mysql_ssl_cert: t.Optional[str],
mysql_ssl_key: t.Optional[str],
mysql_ssl_ca: t.Optional[str],
skip_ssl: bool,
chunk: int,
log_file: t.Union[str, "os.PathLike[t.Any]"],
Expand Down Expand Up @@ -219,6 +225,9 @@ def cli(
mysql_port=mysql_port,
mysql_charset=mysql_charset,
mysql_collation=mysql_collation,
mysql_ssl_cert=mysql_ssl_cert,
mysql_ssl_key=mysql_ssl_key,
mysql_ssl_ca=mysql_ssl_ca,
mysql_ssl_disabled=skip_ssl,
chunk=chunk,
json_as_text=json_as_text,
Expand Down
9 changes: 9 additions & 0 deletions src/mysql_to_sqlite3/transporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ def __init__(self, **kwargs: tx.Unpack[MySQLtoSQLiteParams]) -> None:
if self._without_tables and self._without_data:
raise ValueError("Unable to continue without transferring data or creating tables!")

self._mysql_ssl_ca = kwargs.get("mysql_ssl_ca") or None

self._mysql_ssl_cert = kwargs.get("mysql_ssl_cert") or None

self._mysql_ssl_key = kwargs.get("mysql_ssl_key") or None

self._mysql_ssl_disabled = bool(kwargs.get("mysql_ssl_disabled", False))

self._current_chunk_number = 0
Expand Down Expand Up @@ -135,6 +141,9 @@ def __init__(self, **kwargs: tx.Unpack[MySQLtoSQLiteParams]) -> None:
password=self._mysql_password,
host=self._mysql_host,
port=self._mysql_port,
ssl_ca=self._mysql_ssl_ca,
ssl_cert=self._mysql_ssl_cert,
ssl_key=self._mysql_ssl_key,
ssl_disabled=self._mysql_ssl_disabled,
charset=self._mysql_charset,
collation=self._mysql_collation,
Expand Down

0 comments on commit 7f626c8

Please sign in to comment.