Install & Compatibility
Where this runs
tested against v0.11.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.132s · 19MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.1s · import 0.118s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SQLiteTrie
✓ from sqltrie import SQLiteTrie
✗ from sqltrie import Trie
JSONTrie
✓ from sqltrie import JSONTrie
SerializedTrie
✓ from sqltrie import SerializedTrie
This quickstart demonstrates common `SQLTrie` operations, including storing and retrieving values by key, checking key existence, and iterating over items with a given prefix. It highlights the use of a context manager for proper database handling and implicitly showcases data persistence in the SQLite backend.
import os
from sqltrie import Trie
db_path = 'my_sqltrie.db'
# Ensure a clean slate for the example
if os.path.exists(db_path):
os.remove(db_path)
# Initialize a SQLTrie instance, typically taking a filename for SQLite storage.
# Using a context manager ensures proper closing and data persistence.
with Trie(filename=db_path) as trie:
trie["apple"] = 100
trie["apricot"] = 200
trie["banana"] = 300
trie["bandana"] = 400
trie["applepie"] = 50
print(f"Value for 'apple': {trie['apple']}")
print(f"'banana' exists: {'banana' in trie}")
print(f"'grape' exists: {'grape' in trie}")
print("\nItems with prefix 'ap':")
for key, value in trie.items(prefix="ap"):
print(f" {key}: {value}")
print("\nAll items:")
for key, value in trie.items():
print(f" {key}: {value}")
# Data is persisted after exiting the 'with' block.
# To verify, load the trie again from the same file.
with Trie(filename=db_path) as loaded_trie:
print(f"\nValue for 'apricot' after reload: {loaded_trie['apricot']}")
print(f"'applepie' exists after reload: {'applepie' in loaded_trie}")
# Clean up the database file
os.remove(db_path)
print(f"\nCleaned up database file '{db_path}'.")
Debug
Known issues
breakingThe library is currently in 'Development Status :: 1 - Planning' (Alpha) as per its PyPI classifier. This indicates a highly unstable API that is subject to frequent and significant breaking changes without prior notice. It is not recommended for production environments.fixRegularly monitor the project's GitHub repository for updates, changes, and potential discussions about API stability. Be prepared to adapt your code with each new release.
affects: All versions prior to 1.0.0
gotchaOfficial documentation, particularly for usage examples and API specifics, is minimal. The 'Usage' section in the PyPI description and GitHub README is marked as 'TODO'. Users will likely need to infer functionality from the source code or common patterns of similar trie implementations.fixExamine the library's source code on GitHub for detailed understanding of its classes and methods. Refer to the documentation of inspiration libraries like `pygtrie` for general trie interface expectations.
affects: All versions
gotchaAs `sqltrie` is backed by SQLite, ensuring data persistence requires proper closing of the trie instance. Failing to do so (e.g., due to unhandled exceptions or abrupt program termination outside of a context manager) may result in data loss or corruption. Always use a context manager (`with Trie(...)`) or explicitly call a `close()` method if available.fixWrap `Trie` instantiation and operations within a `with` statement (e.g., `with Trie(filename='my_db.db') as trie:`) to ensure resources are properly managed and data is committed to disk.
affects: All versions
Upgrade
Version history
0.11.2latest on PyPI · released Feb 19, 2025
Audit
Dependencies
No dependency data recorded yet.