kglite
raw JSON → 0.8.34 verified Fri May 01 auth: no python
High-performance graph database library with Python bindings written in Rust. Current version 0.8.34, requires Python >=3.10. Active development with frequent releases (weekly to bi-weekly).
pip install kglite Common errors
error ModuleNotFoundError: No module named 'kglite' ↓
cause kglite not installed (requires Python >=3.10).
fix
pip install kglite
error AttributeError: module 'kglite' has no attribute 'Graph' ↓
cause Old version of kglite (<0.8?) or typo (case-sensitive).
fix
Upgrade: pip install -U kglite. Import: import kglite; kglite.Graph()
Warnings
gotcha Default Cypher query timeout changed per version. In 0.8.27 the default timeout was unified to 180_000 ms (3 min) for all storage modes. Previously memory had no default, mapped was 60s, disk was 10s. Set timeout_ms=0 to disable. ↓
fix Upgrade to >=0.8.27 or explicitly pass timeout_ms=0 for unbounded queries.
breaking Graph load from disk (slice-built) changed in 0.8.28, adding binary sidecars. Old serialized graphs may not load correctly. Rebuild graphs with current version. ↓
fix Regenerate any persisted graphs using kglite >=0.8.28.
deprecated The code_tree module (for AST-based code parsing) may change. Not yet stable API. ↓
fix Avoid relying on code_tree internals; use only public Cypher query API for production.
gotcha Memory-mapped and disk storage modes have different performance characteristics. Use 'in_memory' for small graphs, 'mapped' for large graphs that fit in virtual memory, 'disk' for huge graphs that must be paged. ↓
fix Read documentation on storage modes before choosing one.
Imports
- kglite
import kglite
Quickstart
import kglite
# Create an in-memory graph
g = kglite.Graph()
# Add nodes and edges
g.add_node("1", labels=["Person"], properties={"name": "Alice"})
g.add_node("2", labels=["Person"], properties={"name": "Bob"})
g.add_edge("1", "2", "KNOWS")
# Run a Cypher query
result = g.run("MATCH (a:Person)-[:KNOWS]->(b:Person) RETURN a.name, b.name")
for row in result:
print(row)