diff --git a/README.md b/README.md index 4a414fb..830ad8c 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Options: --mysql-password TEXT MySQL password -h, --mysql-host TEXT MySQL host. Defaults to localhost. -P, --mysql-port INTEGER MySQL port. Defaults to 3306. + --mysql-socket TEXT Path to MySQL unix socket file. -S, --skip-ssl Disable MySQL connection encryption. -i, --mysql-insert-method [DEFAULT|IGNORE|UPDATE] MySQL insert method. DEFAULT will throw diff --git a/docs/README.rst b/docs/README.rst index cfdf8e1..5da0526 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -29,6 +29,7 @@ Connection Options - ``-h, --mysql-host TEXT``: MySQL host. Defaults to localhost. - ``-P, --mysql-port INTEGER``: MySQL port. Defaults to 3306. - ``-S, --skip-ssl``: Disable MySQL connection encryption. +- ``--mysql-socket TEXT``: Path to MySQL unix socket file. Transfer Options """""""""""""""" diff --git a/src/sqlite3_to_mysql/cli.py b/src/sqlite3_to_mysql/cli.py index 7391256..216db50 100644 --- a/src/sqlite3_to_mysql/cli.py +++ b/src/sqlite3_to_mysql/cli.py @@ -62,6 +62,7 @@ @click.option("--mysql-password", default=None, help="MySQL password") @click.option("-h", "--mysql-host", default="localhost", help="MySQL host. Defaults to localhost.") @click.option("-P", "--mysql-port", type=int, default=3306, help="MySQL port. Defaults to 3306.") +@click.option("--mysql-socket", default=None, help="Path to MySQL unix socket file.") @click.option("-S", "--skip-ssl", is_flag=True, help="Disable MySQL connection encryption.") @click.option( "-i", @@ -137,6 +138,7 @@ def cli( mysql_database: str, mysql_host: str, mysql_port: int, + mysql_socket: str, skip_ssl: bool, mysql_insert_method: str, mysql_truncate_tables: bool, @@ -183,6 +185,7 @@ def cli( mysql_database=mysql_database, mysql_host=mysql_host, mysql_port=mysql_port, + mysql_socket=mysql_socket, mysql_ssl_disabled=skip_ssl, mysql_insert_method=mysql_insert_method, mysql_truncate_tables=mysql_truncate_tables, diff --git a/src/sqlite3_to_mysql/transporter.py b/src/sqlite3_to_mysql/transporter.py index 9250f21..4eabc11 100644 --- a/src/sqlite3_to_mysql/transporter.py +++ b/src/sqlite3_to_mysql/transporter.py @@ -75,6 +75,8 @@ def __init__(self, **kwargs: tx.Unpack[SQLite3toMySQLParams]): self._mysql_port = kwargs.get("mysql_port", 3306) or 3306 + self._mysql_socket = str(kwargs.get("mysql_socket")) if kwargs.get("mysql_socket") else None + self._sqlite_tables = kwargs.get("sqlite_tables") or tuple() self._without_foreign_keys = bool(self._sqlite_tables) or bool(kwargs.get("without_foreign_keys", False)) @@ -144,6 +146,7 @@ def __init__(self, **kwargs: tx.Unpack[SQLite3toMySQLParams]): password=self._mysql_password, host=self._mysql_host, port=self._mysql_port, + unix_socket=self._mysql_socket, ssl_disabled=self._mysql_ssl_disabled, use_pure=True, charset=self._mysql_charset, diff --git a/src/sqlite3_to_mysql/types.py b/src/sqlite3_to_mysql/types.py index d6082f4..4411357 100644 --- a/src/sqlite3_to_mysql/types.py +++ b/src/sqlite3_to_mysql/types.py @@ -20,6 +20,7 @@ class SQLite3toMySQLParams(tx.TypedDict): mysql_password: t.Optional[t.Union[str, bool]] mysql_host: t.Optional[str] mysql_port: t.Optional[int] + mysql_socket: t.Optional[str] mysql_ssl_disabled: t.Optional[bool] chunk: t.Optional[int] quiet: t.Optional[bool] @@ -49,6 +50,7 @@ class SQLite3toMySQLAttributes: _mysql_password: t.Optional[str] _mysql_host: str _mysql_port: int + _mysql_socket: str _mysql_ssl_disabled: bool _chunk_size: t.Optional[int] _quiet: bool