-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ added a --mysql-socket option to connect to MySQL using a Unix socket #129
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -74,6 +74,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)) | ||||||||||||||
|
@@ -143,6 +145,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, | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding socket path validation. While the implementation is correct, consider validating the socket path's existence before attempting the connection to provide a more user-friendly error message. + unix_socket=(
+ self._mysql_socket
+ if self._mysql_socket and os.path.exists(self._mysql_socket)
+ else None
+ ),
- unix_socket=self._mysql_socket, This change would help users identify socket path issues before MySQL Connector attempts the connection. 📝 Committable suggestion
Suggested change
|
||||||||||||||
ssl_disabled=self._mysql_ssl_disabled, | ||||||||||||||
use_pure=True, | ||||||||||||||
charset=self._mysql_charset, | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type inconsistency between parameter and attribute definitions The Apply this change to maintain consistency: - _mysql_socket: str
+ _mysql_socket: t.Optional[str] 📝 Committable suggestion
Suggested change
|
||||||
_mysql_ssl_disabled: bool | ||||||
_chunk_size: t.Optional[int] | ||||||
_quiet: bool | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update type annotation for mysql_socket parameter
The parameter should be marked as optional since it has a None default value.
📝 Committable suggestion