-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
✨ add --without-tables
option
#78
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant Transporter
participant MySQL
participant SQLite
User->>CLI: Execute mysql2sqlite with -Z/--without-tables
CLI->>Transporter: Pass parameters including without_tables=True
Transporter->>MySQL: Fetch data without table structures
MySQL-->>Transporter: Return data
Transporter->>SQLite: Insert data into existing tables
SQLite-->>Transporter: Confirm data insertion
Transporter-->>CLI: Transfer complete
CLI-->>User: Success message
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #78 +/- ##
==========================================
+ Coverage 87.04% 87.07% +0.02%
==========================================
Files 8 8
Lines 579 588 +9
==========================================
+ Hits 504 512 +8
- Misses 75 76 +1 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 5
Outside diff range and nitpick comments (4)
README.md (1)
34-34
: Update the copyright year to maintain accuracy.Consider updating the copyright year to reflect the current year, ensuring that the documentation remains accurate and up-to-date.
src/mysql_to_sqlite3/transporter.py (3)
60-60
: Ensure consistent use of default values and boolean conversions.The code consistently uses a pattern of
kwargs.get("key", default) or default
for default values and boolean conversions. This is generally fine, but be aware that it can lead to unexpected behaviour ifkwargs.get("key")
returns a value that Python evaluates toFalse
(like0
,''
,[]
, etc.), even if it's a valid value. Consider using a more explicit check if this could be a concern.Also applies to: 62-62, 68-68, 71-71, 82-82, 84-87, 89-90, 92-93, 95-95, 101-101, 103-103, 105-105, 120-120
Line range hint
305-308
: Refactor to usecontextlib.suppress
for cleaner exception handling.Instead of using a
try-except-pass
block, usecontextlib.suppress
to ignore exceptions. This makes the code cleaner and more Pythonic.- try: - return column_type.decode() - except (UnicodeDecodeError, AttributeError): - pass + from contextlib import suppress + with suppress(UnicodeDecodeError, AttributeError): + return column_type.decode()
Line range hint
359-368
: Simplify nestedif
statements.The nested
if
statements can be combined into a singleif
statement for clarity and reduced complexity.- if index["primary"] in {1, "1"}: - if (index["auto_increment"] not in {1, "1"}) or any( - self._translate_type_from_mysql_to_sqlite( - column_type=_type, - sqlite_json1_extension_enabled=self._sqlite_json1_extension_enabled, - ) - not in Integer_Types - for _type in types.split(",") - ): - primary += "\n\tPRIMARY KEY ({})".format( - ", ".join(f'"{column}"' for column in columns.split(",")) - ) + if index["primary"] in {1, "1"} and (index["auto_increment"] not in {1, "1"} or any( + self._translate_type_from_mysql_to_sqlite( + column_type=_type, + sqlite_json1_extension_enabled=self._sqlite_json1_extension_enabled, + ) + not in Integer_Types + for _type in types.split(",") + )): + primary += "\n\tPRIMARY KEY ({})".format( + ", ".join(f'"{column}"' for column in columns.split(",")) + )
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- README.md (3 hunks)
- docs/README.rst (1 hunks)
- src/mysql_to_sqlite3/cli.py (4 hunks)
- src/mysql_to_sqlite3/transporter.py (5 hunks)
- src/mysql_to_sqlite3/types.py (2 hunks)
- tests/func/mysql_to_sqlite3_test.py (1 hunks)
- tests/func/test_cli.py (1 hunks)
Files skipped from review due to trivial changes (1)
- docs/README.rst
Additional context used
LanguageTool
README.md
[locale-violation] ~5-~5: license must be spelled with a “c” when used as a noun in British English. Use “licence”. (LICENCE_LICENSE_NOUN_SINGULAR)
Context: ...10.2+|+10.3+|+10.4+|+10.5&color=C0765A) [![GitHub license](https://img.shields.io/github/license/...
Markdownlint
README.md
20-20: Expected: h2; Actual: h4 (MD001, heading-increment)
Heading levels should only increment by one level at a time
20-20: Punctuation: '.' (MD026, no-trailing-punctuation)
Trailing punctuation in heading
31-31: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified
Ruff
src/mysql_to_sqlite3/transporter.py
305-308: Use
contextlib.suppress(UnicodeDecodeError, AttributeError)
instead oftry
-except
-pass
(SIM105)Replace with
contextlib.suppress(UnicodeDecodeError, AttributeError)
359-368: Use a single
if
statement instead of nestedif
statements (SIM102)
Additional comments not posted (4)
src/mysql_to_sqlite3/cli.py (1)
96-100
: The new CLI option is well-integrated and documented.The addition of the
--without-tables
option is clear and follows the existing pattern of CLI options. The help message is concise and informative.README.md (1)
63-63
: The new CLI options are well-documented in the README.The addition of the
-Z, --without-tables
and-W, --without-data
options are clearly documented, providing users with straightforward guidance on their usage.tests/func/test_cli.py (2)
222-248
: Ensure comprehensive testing of the--without-data
option.The test case for the
--without-data
option is well-constructed, ensuring that the functionality behaves as expected when this option is used.
249-295
: Validate the functionality of the--without-tables
option through testing.The test case for the
--without-tables
option is thorough, covering scenarios where tables are not transferred. This ensures that the new functionality is robust and behaves as intended.
Description
This PR adds the option
--without-tables
which enables a user to skip table creation and transfer only data.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
CLI and function tests.
Checklist: