-
Notifications
You must be signed in to change notification settings - Fork 86
Replace sqlite3 with sqlean #220
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
Conversation
@@ -361,7 +361,7 @@ def run_cli(self): | |||
else: | |||
history = None | |||
self.echo( | |||
'Error: Unable to open the history file "{}". ' "Your query history will not be saved.".format(history_file), | |||
'Error: Unable to open the history file "{}". Your query history will not be saved.'.format(history_file), |
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.
All the formatting done by ruff.
assert set(executor.table_columns()) == set([("a", "x"), ("a", "y"), ("b", "z"), ("t", "t")]) | ||
assert set(executor.tables()) == set([("sqlean_define",), ("a",), ("b",), ("t",)]) | ||
assert set(executor.table_columns()) == set( | ||
[("sqlean_define", "type"), ("sqlean_define", "body"), ("sqlean_define", "name"), ("a", "x"), ("a", "y"), ("b", "z"), ("t", "t")] |
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.
Adding extra table and columns from sqlean define
Here is a simple benchmark # -*- coding: utf-8 -*-
from litecli.main import LiteCli
import timeit
def perf():
dbname=":memory:"
cli = LiteCli()
cli.connect(dbname)
# Create a table
cli.run_query("create table test (a text)")
# Insert 10000 rows
for i in range(10000):
cli.run_query(f'insert into test values("{i}")')
# Delete the table
cli.run_query("drop table test")
def main():
# timeit is not needed when using hyperfine
print(timeit.timeit("perf()", globals=globals(), number=10))
if __name__ == "__main__":
main() Default Sqlite3
Sqlean
I don't see much deviation in performance and I think it should be okay. Let me know what you think. |
I am definitely intrigued. I'll give it a shot today. One thing to consider is the additional friction in installation. The sqlean package is a C-extension. I see they have wheels for a supported platforms. But this does introduce an additional dependency that is not part of the std lib. I'm wondering if we can make this an optional package. For instance, a power user could install
Then check for sqlean being not None before we use it. Just some initial thoughts. |
That's an another approach. We can update docs to say it. That also means majority of the users have to discover the feature from reading the docs. try:
import sqlean
except ImportError:
sqlean = None Above code we can look for sqlean if not fallback to sqlite3 try:
import sqlean as sqlite3
except ImportError:
import sqlite3 And also fix import exceptions in the code. This can be downside. I see everytime any import from sqlite3 module needs to always have |
Closing this PR in favour of #221 |
Description
Notes:
Checklist
CHANGELOG.md
file.