-
Notifications
You must be signed in to change notification settings - Fork 226
Reduce query parameter size for sqlite #6889
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
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6889 +/- ##
==========================================
+ Coverage 78.59% 78.61% +0.02%
==========================================
Files 567 567
Lines 43092 43117 +25
==========================================
+ Hits 33865 33892 +27
+ Misses 9227 9225 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I suggest to put a batch of ~950 (in any case < 999), see my discussion here (good to maybe copy the discussion also here): |
This was quick-and-dirty to try out. My idea was to determine the limit beforehand and use this. This script I got from ChatGPT but did not verified it yet. import sqlite3
conn = sqlite3.connect(":memory:")
cur = conn.cursor()
# Try increasing numbers until an error occurs
max_vars = 1
try:
while True:
placeholders = ",".join(["?"] * max_vars)
query = f"SELECT {placeholders}"
cur.execute(query, [None] * max_vars)
max_vars += 1
except sqlite3.OperationalError as e:
print(f"Maximum number of variables supported: {max_vars - 1}") EDIT: The script seems not really nice. I think the global variable with the doc that @giovannipizzi posted is nicer solution. EDIT2: There is the |
Sqlite only accepts a limited number of parameters so we reduce the query into chunks
Fix #6876
TODO: