Skip to content

Commit 69b6d43

Browse files
committedOct 23, 2024
added --mysql-socket option for unix socket path
1 parent 89009d4 commit 69b6d43

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed
 

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Options:
5151
--mysql-password TEXT MySQL password
5252
-h, --mysql-host TEXT MySQL host. Defaults to localhost.
5353
-P, --mysql-port INTEGER MySQL port. Defaults to 3306.
54+
--mysql-socket TEXT Path to MySQL unix socket file.
5455
-S, --skip-ssl Disable MySQL connection encryption.
5556
-i, --mysql-insert-method [DEFAULT|IGNORE|UPDATE]
5657
MySQL insert method. DEFAULT will throw

‎docs/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Connection Options
2929
- ``-h, --mysql-host TEXT``: MySQL host. Defaults to localhost.
3030
- ``-P, --mysql-port INTEGER``: MySQL port. Defaults to 3306.
3131
- ``-S, --skip-ssl``: Disable MySQL connection encryption.
32+
- ``--mysql-socket TEXT``: Path to MySQL unix socket file.
3233

3334
Transfer Options
3435
""""""""""""""""

‎src/sqlite3_to_mysql/cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
@click.option("--mysql-password", default=None, help="MySQL password")
6363
@click.option("-h", "--mysql-host", default="localhost", help="MySQL host. Defaults to localhost.")
6464
@click.option("-P", "--mysql-port", type=int, default=3306, help="MySQL port. Defaults to 3306.")
65+
@click.option("--mysql-socket", default=None, help="Path to MySQL unix socket file.")
6566
@click.option("-S", "--skip-ssl", is_flag=True, help="Disable MySQL connection encryption.")
6667
@click.option(
6768
"-i",
@@ -137,6 +138,7 @@ def cli(
137138
mysql_database: str,
138139
mysql_host: str,
139140
mysql_port: int,
141+
mysql_socket: str,
140142
skip_ssl: bool,
141143
mysql_insert_method: str,
142144
mysql_truncate_tables: bool,
@@ -183,6 +185,7 @@ def cli(
183185
mysql_database=mysql_database,
184186
mysql_host=mysql_host,
185187
mysql_port=mysql_port,
188+
mysql_socket=mysql_socket,
186189
mysql_ssl_disabled=skip_ssl,
187190
mysql_insert_method=mysql_insert_method,
188191
mysql_truncate_tables=mysql_truncate_tables,

‎src/sqlite3_to_mysql/transporter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def __init__(self, **kwargs: tx.Unpack[SQLite3toMySQLParams]):
7474

7575
self._mysql_port = kwargs.get("mysql_port", 3306) or 3306
7676

77+
self._mysql_socket = str(kwargs.get("mysql_socket")) if kwargs.get("mysql_socket") else None
78+
7779
self._sqlite_tables = kwargs.get("sqlite_tables") or tuple()
7880

7981
self._without_foreign_keys = bool(self._sqlite_tables) or bool(kwargs.get("without_foreign_keys", False))
@@ -143,6 +145,7 @@ def __init__(self, **kwargs: tx.Unpack[SQLite3toMySQLParams]):
143145
password=self._mysql_password,
144146
host=self._mysql_host,
145147
port=self._mysql_port,
148+
unix_socket=self._mysql_socket,
146149
ssl_disabled=self._mysql_ssl_disabled,
147150
use_pure=True,
148151
charset=self._mysql_charset,

‎src/sqlite3_to_mysql/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class SQLite3toMySQLParams(tx.TypedDict):
2020
mysql_password: t.Optional[t.Union[str, bool]]
2121
mysql_host: t.Optional[str]
2222
mysql_port: t.Optional[int]
23+
mysql_socket: t.Optional[str]
2324
mysql_ssl_disabled: t.Optional[bool]
2425
chunk: t.Optional[int]
2526
quiet: t.Optional[bool]
@@ -49,6 +50,7 @@ class SQLite3toMySQLAttributes:
4950
_mysql_password: t.Optional[str]
5051
_mysql_host: str
5152
_mysql_port: int
53+
_mysql_socket: str
5254
_mysql_ssl_disabled: bool
5355
_chunk_size: t.Optional[int]
5456
_quiet: bool

0 commit comments

Comments
 (0)