Skip to content

✨ MySQL Unix socket connection support #137

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

Merged
merged 11 commits into from
Jul 13, 2025
Merged

✨ MySQL Unix socket connection support #137

merged 11 commits into from
Jul 13, 2025

Conversation

techouse
Copy link
Owner

This pull request introduces support for specifying a MySQL Unix socket file in the sqlite3_to_mysql tool. The changes include updates to the CLI, internal logic, and test cases to accommodate this new feature.

New Feature: MySQL Unix Socket Support

  • CLI Updates:

    • Added a new --mysql-socket option to the CLI for specifying the path to a MySQL Unix socket file. This option is mutually exclusive with the --mysql-port option. (README.md [1] docs/README.rst [2] src/sqlite3_to_mysql/cli.py [3] [4] [5]
  • Internal Logic:

    • Updated the SQLite3toMySQLParams and SQLite3toMySQLAttributes classes to include a mysql_socket attribute. (src/sqlite3_to_mysql/types.py [1] [2]
    • Modified the SQLite3toMySQL transporter to handle the mysql_socket parameter. If a socket is provided, it overrides the mysql_port setting. Validation ensures the socket file exists. (src/sqlite3_to_mysql/transporter.py [1] [2]
  • Testing Enhancements:

    • Extended unit tests to include scenarios for the mysql_socket parameter, ensuring proper handling and validation. (tests/unit/types_test.py [1] [2] [3] [4]

Supersedes #129

@techouse techouse self-assigned this Jul 13, 2025
@techouse techouse added the enhancement New feature or request label Jul 13, 2025
Copy link

coderabbitai bot commented Jul 13, 2025

Walkthrough

A new command-line option and supporting logic were introduced to allow specifying a MySQL Unix socket file for connections in the sqlite3mysql tool. Documentation, type definitions, and tests were updated to reflect and validate this new feature, enabling connections via Unix socket as an alternative to TCP/IP.

Changes

File(s) Change Summary
README.md, docs/README.rst Documentation updated to describe the new --mysql-socket/-k command-line option for specifying a Unix socket.
src/sqlite3_to_mysql/cli.py Added --mysql-socket option; updated cli function to accept and forward the mysql_socket parameter.
src/sqlite3_to_mysql/transporter.py Enhanced SQLite3toMySQL to support and validate a mysql_socket parameter; updated MySQL connection logic.
src/sqlite3_to_mysql/types.py Extended type definitions to include an optional mysql_socket parameter and attribute.
tests/unit/types_test.py Tests updated to include and validate the mysql_socket parameter and attribute in mocks and assertions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant SQLite3toMySQL
    participant MySQL

    User->>CLI: Run with --mysql-socket PATH
    CLI->>SQLite3toMySQL: Instantiate with mysql_socket=PATH
    SQLite3toMySQL->>Filesystem: Validate PATH exists
    SQLite3toMySQL->>MySQL: Connect using unix_socket=PATH
    MySQL-->>SQLite3toMySQL: Connection established via socket
Loading

Poem

A socket path now joins the fun,
For MySQL connections, one by one!
No more just ports, or hosts to seek—
A Unix file, unique and sleek.
The docs and types all know its name,
The tests agree: it's in the game!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 168a2f5 and 2ad89e1.

📒 Files selected for processing (1)
  • src/sqlite3_to_mysql/cli.py (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/sqlite3_to_mysql/cli.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Test (python3.11, mysql:8.0, 0, false, 3.11)
  • GitHub Check: Test (python3.13, mysql:8.0, 0, false, 3.13)
  • GitHub Check: Test (python3.9, mysql:5.7, 0, false, 3.9)
  • GitHub Check: Test (python3.10, mysql:5.6, 1, false, 3.10)
  • GitHub Check: Test (python3.12, mysql:5.7, 0, false, 3.12)
  • GitHub Check: Test (python3.10, mariadb:11.8, 0, false, 3.10)
  • GitHub Check: Test (python3.13, mariadb:10.11, 0, false, 3.13)
  • GitHub Check: Test (python3.12, mariadb:10.11, 0, false, 3.12)
  • GitHub Check: Test (python3.12, mariadb:10.0, 1, false, 3.12)
  • GitHub Check: Test (python3.13, mariadb:10.0, 1, false, 3.13)
  • GitHub Check: Test (python3.9, mariadb:10.11, 0, false, 3.9)
  • GitHub Check: Test (python3.13, mariadb:10.6, 0, false, 3.13)
  • GitHub Check: Test (python3.12, mariadb:10.6, 0, false, 3.12)
  • GitHub Check: Test (python3.9, mariadb:10.6, 0, false, 3.9)
  • GitHub Check: Test (python3.10, mariadb:10.6, 0, false, 3.10)
  • GitHub Check: Test (python3.13, mariadb:5.5, 1, false, 3.13)
  • GitHub Check: Test (python3.9, mariadb:10.0, 1, false, 3.9)
  • GitHub Check: Test (python3.10, mariadb:5.5, 1, false, 3.10)
  • GitHub Check: Test (python3.12, mariadb:5.5, 1, false, 3.12)
  • GitHub Check: Test (python3.9, mariadb:5.5, 1, false, 3.9)
  • GitHub Check: Codacy Static Code Analysis
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@techouse techouse changed the title ✨ add MySQL Unix socket connection support ✨ MySQL Unix socket connection support Jul 13, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d7031d and 168a2f5.

📒 Files selected for processing (6)
  • README.md (1 hunks)
  • docs/README.rst (1 hunks)
  • src/sqlite3_to_mysql/cli.py (3 hunks)
  • src/sqlite3_to_mysql/transporter.py (2 hunks)
  • src/sqlite3_to_mysql/types.py (2 hunks)
  • tests/unit/types_test.py (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Test (python3.13, mysql:5.7, 0, false, 3.13)
  • GitHub Check: Test (python3.10, mysql:5.7, 0, false, 3.10)
  • GitHub Check: Test (python3.11, mariadb:11.8, 0, false, 3.11)
  • GitHub Check: Test (python3.9, mariadb:11.4, 0, false, 3.9)
  • GitHub Check: Test (python3.10, mariadb:11.8, 0, false, 3.10)
  • GitHub Check: Test (python3.12, mariadb:11.8, 0, false, 3.12)
  • GitHub Check: Test (python3.11, mariadb:10.11, 0, false, 3.11)
  • GitHub Check: Test (python3.10, mariadb:10.11, 0, false, 3.10)
  • GitHub Check: Test (python3.9, mariadb:10.11, 0, false, 3.9)
  • GitHub Check: Test (python3.9, mariadb:10.6, 0, false, 3.9)
  • GitHub Check: Test (python3.12, mariadb:10.6, 0, false, 3.12)
  • GitHub Check: Test (python3.10, mariadb:10.6, 0, false, 3.10)
  • GitHub Check: Test (python3.13, mariadb:5.5, 1, false, 3.13)
  • GitHub Check: Test (python3.10, mariadb:10.0, 1, false, 3.10)
  • GitHub Check: Test (python3.11, mariadb:5.5, 1, false, 3.11)
  • GitHub Check: Test (python3.10, mariadb:5.5, 1, false, 3.10)
  • GitHub Check: Test (python3.9, mariadb:10.0, 1, false, 3.9)
  • GitHub Check: Test (python3.11, mariadb:10.0, 1, false, 3.11)
  • GitHub Check: Test (python3.12, mariadb:5.5, 1, false, 3.12)
  • GitHub Check: Test (python3.9, mariadb:5.5, 1, false, 3.9)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (10)
docs/README.rst (1)

32-32: Documentation looks good.

The new socket option is properly documented with a clear description.

README.md (1)

52-52: Documentation is consistent and clear.

The CLI option documentation follows the established format and provides a clear description.

src/sqlite3_to_mysql/cli.py (2)

147-147: Parameter typing is correct.

The optional string typing for mysql_socket is appropriate.


194-194: Parameter passing looks correct.

The mysql_socket parameter is properly passed to the SQLite3toMySQL constructor.

tests/unit/types_test.py (2)

26-26: Test parameter coverage is comprehensive.

The addition of mysql_socket to the test parameters and corresponding assertion provides proper test coverage for the new functionality.

Also applies to: 54-54


95-95: Test attribute coverage is thorough.

The mock class properly includes the _mysql_socket attribute and the assertion validates its presence and value correctly.

Also applies to: 135-135

src/sqlite3_to_mysql/types.py (2)

23-23: New mysql_socket field is properly typed.

The optional typing and PathLike support are consistent with similar fields in the TypedDict.


52-53: No issues found with making _mysql_port optional

I’ve searched every reference to _mysql_port and mysql_port in the codebase:

• In transporter.py, _mysql_port is always defaulted to 3306 (via kwargs.get("mysql_port", 3306) or 3306) and only set to None in the Unix‐socket branch, where unix_socket is supplied.
• The only other use is passing port=self._mysql_port into the connector; no arithmetic or assumptions are made on it.
• All unit and functional tests that set or assert on _mysql_port use concrete integers, and there are no code paths that dereference it without checking the socket case.

Optional[int] for _mysql_port therefore does not introduce any breaking changes.

src/sqlite3_to_mysql/transporter.py (2)

78-85: Well-implemented socket validation and mutual exclusivity logic.

The socket parameter handling is robust and follows good practices:

  • Early validation with appropriate error handling
  • Proper use of realpath for resolving symlinks
  • Enforcement of mutual exclusivity by setting mysql_port to None
  • Consistent with the existing codebase patterns

156-156: Correct implementation of Unix socket connection parameter.

The addition of the unix_socket parameter to the MySQL connection is properly implemented according to the mysql.connector API.

Copy link

codecov bot commented Jul 13, 2025

Codecov Report

Attention: Patch coverage is 58.33333% with 5 lines in your changes missing coverage. Please review.

Project coverage is 95.11%. Comparing base (9d7031d) to head (2ad89e1).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/sqlite3_to_mysql/transporter.py 33.33% 4 Missing ⚠️
src/sqlite3_to_mysql/cli.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #137      +/-   ##
==========================================
- Coverage   95.78%   95.11%   -0.68%     
==========================================
  Files           8        8              
  Lines         664      675      +11     
==========================================
+ Hits          636      642       +6     
- Misses         28       33       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@techouse techouse merged commit aa0a092 into master Jul 13, 2025
61 of 63 checks passed
@techouse techouse deleted the socket branch July 13, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants