Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
A one-liner to output details of the current Python’s SQLite#
In investigating llm/issues/164 I found myself needing to know more precise details of the Python SQLite environment used by the reporter of the bug.
I came up with this one-liner for pasting into a terminal:
1python -c '2import sqlite33import sys4conn = sqlite3.connect(":memory:")5print("Python version:", sys.version)6print("SQLite version:", conn.execute("select sqlite_version()").fetchone()[0])7print("SQLite compile options\n " + "\n ".join(r[0] for r in conn.execute("pragma compile_options").fetchall()))8for pragma in (9 "foreign_keys", "defer_foreign_keys", "ignore_check_constraints", "legacy_alter_table",10 "recursive_triggers", "writable_schema",11 ):12 output = conn.execute("pragma %s" % pragma).fetchone()13 print("Pragma {}: {}".format(pragma, output[0]))14'The output on my machine looks like this:
1Python version: 3.10.10 (main, Mar 21 2023, 13:41:05) [Clang 14.0.6 ]2SQLite version: 3.41.13SQLite compile options4 ATOMIC_INTRINSICS=15 COMPILER=clang-14.0.66 DEFAULT_AUTOVACUUM7 DEFAULT_CACHE_SIZE=-20008 DEFAULT_FILE_FORMAT=49 DEFAULT_JOURNAL_SIZE_LIMIT=-110 DEFAULT_MMAP_SIZE=011 DEFAULT_PAGE_SIZE=409612 DEFAULT_PCACHE_INITSZ=2013 DEFAULT_RECURSIVE_TRIGGERS14 DEFAULT_SECTOR_SIZE=409615 DEFAULT_SYNCHRONOUS=216 DEFAULT_WAL_AUTOCHECKPOINT=100017 DEFAULT_WAL_SYNCHRONOUS=218 DEFAULT_WORKER_THREADS=019 ENABLE_COLUMN_METADATA20 ENABLE_DBSTAT_VTAB21 ENABLE_FTS322 ENABLE_FTS3_TOKENIZER23 ENABLE_FTS424 ENABLE_FTS525 ENABLE_GEOPOLY26 ENABLE_MATH_FUNCTIONS27 ENABLE_RTREE28 ENABLE_UNLOCK_NOTIFY29 MALLOC_SOFT_LIMIT=102430 MAX_ATTACHED=1031 MAX_COLUMN=200032 MAX_COMPOUND_SELECT=50033 MAX_DEFAULT_PAGE_SIZE=819234 MAX_EXPR_DEPTH=1000035 MAX_FUNCTION_ARG=12736 MAX_LENGTH=100000000037 MAX_LIKE_PATTERN_LENGTH=5000038 MAX_MMAP_SIZE=0x7fff000039 MAX_PAGE_COUNT=107374182340 MAX_PAGE_SIZE=6553641 MAX_SQL_LENGTH=100000000042 MAX_TRIGGER_DEPTH=100043 MAX_VARIABLE_NUMBER=25000044 MAX_VDBE_OP=25000000045 MAX_WORKER_THREADS=846 MUTEX_PTHREADS47 SECURE_DELETE48 SYSTEM_MALLOC49 TEMP_STORE=150 THREADSAFE=151Pragma foreign_keys: 052Pragma defer_foreign_keys: 053Pragma ignore_check_constraints: 054Pragma legacy_alter_table: 055Pragma recursive_triggers: 056Pragma writable_schema: 0The script works by querying pragma compile_options for the compilation options, then looping through and checking some boolean pragmas as well.
Full documentation on available SQLite pragmas is here.
Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.