Skip to content

Amjith/sqlean optional #221

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 12 commits into from
Apr 21, 2025
Merged

Amjith/sqlean optional #221

merged 12 commits into from
Apr 21, 2025

Conversation

amjith
Copy link
Member

@amjith amjith commented Apr 13, 2025

@kracekumar This is just a draft looking for feedback.

Description

Make sqlean an optional dependency.
Test with and without sqlean.
Update docs to have sqlean as part of the install command.

@amjith amjith requested a review from kracekumar April 13, 2025 17:28

sqlite3.extensions.enable_all()
except ImportError:
import sqlite3

Check notice

Code scanning / CodeQL

Module is imported with 'import' and 'import from' Note

Module 'sqlite3' is imported with both 'import' and 'import from'.

Copilot Autofix

AI 20 days ago

To fix the issue:

  1. Remove the from sqlite3 import OperationalError statement on line 12.
  2. Replace any direct usage of OperationalError with sqlite3.OperationalError in the code.
  3. Ensure that the functionality remains unchanged by testing the code after the fix.

This approach adheres to the recommendation and eliminates the redundant import while maintaining clarity and consistency.

Suggested changeset 1
litecli/sqlexecute.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/litecli/sqlexecute.py b/litecli/sqlexecute.py
--- a/litecli/sqlexecute.py
+++ b/litecli/sqlexecute.py
@@ -6,3 +6,3 @@
     import sqlean as sqlite3
-    from sqlean import OperationalError
+    OperationalError = sqlite3.OperationalError
 
@@ -11,3 +11,2 @@
     import sqlite3
-    from sqlite3 import OperationalError
 from litecli.packages.special.utils import check_if_sqlitedotcommand
EOF
@@ -6,3 +6,3 @@
import sqlean as sqlite3
from sqlean import OperationalError
OperationalError = sqlite3.OperationalError

@@ -11,3 +11,2 @@
import sqlite3
from sqlite3 import OperationalError
from litecli.packages.special.utils import check_if_sqlitedotcommand
Copilot is powered by AI and may make mistakes. Always verify output.
@amjith amjith marked this pull request as ready for review April 19, 2025 04:09
try:
from sqlean import OperationalError, sqlite_version
except ImportError:
from sqlite3 import OperationalError, sqlite_version
Copy link
Contributor

Choose a reason for hiding this comment

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

The import looks fine and should handle the case when sqlean is missing👍🏾


sqlite3.extensions.enable_all()
except ImportError:
import sqlite3
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good to cover missing sqlean.

@@ -27,14 +27,14 @@ def list_tables(cur, arg=None, arg_type=PARSED_QUERY, verbose=False):
args = ("{0}%".format(arg),)
query = """
SELECT name FROM sqlite_master
WHERE type IN ('table','view') AND name LIKE ? AND name NOT LIKE 'sqlite_%'
WHERE type IN ('table','view') AND name LIKE ? AND name NOT LIKE 'sqlite_%' AND name NOT LIKE 'sqlean_define'
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: We can be a bit more generic, like sqlean_%. Not blocking the PR though

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Done!

@kracekumar
Copy link
Contributor

We are good to merge the PR!

@kracekumar kracekumar mentioned this pull request Apr 21, 2025
1 task
@amjith amjith merged commit 76fb4c5 into main Apr 21, 2025
7 checks passed
@amjith amjith deleted the amjith/sqlean-optional branch April 21, 2025 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants