Skip to main content

A high-performance graph database library with Python bindings written in Rust

Project description

KGLite — Lightweight Knowledge Graph for Python

PyPI version Python versions License: MIT Docs

An embedded, in-memory knowledge graph database for Python — built in Rust for speed, with a Cypher query engine, semantic search, and first-class support for RAG pipelines and AI agents. No server, no setup, no infrastructure. Just pip install kglite and go.

Why KGLite?

  • Zero infrastructure — runs inside your Python process. No database server to install, configure, or maintain.
  • Fast — Rust core (via PyO3 + petgraph) with zero-copy where possible. Load millions of nodes without leaving Python.
  • Query with Cypher — familiar graph query language for pattern matching, mutations, aggregations, and traversals.
  • Built for AI — semantic search with text_score(), schema introspection via describe(), and a ready-made MCP server for LLM tool use.
  • DataFrames in, DataFrames out — bulk-load from pandas, query results as DataFrames. Fits naturally into data science workflows.

Quick Start

pip install kglite
import kglite

graph = kglite.KnowledgeGraph()

# Create nodes and relationships
graph.cypher("CREATE (:Person {name: 'Alice', age: 28, city: 'Oslo'})")
graph.cypher("CREATE (:Person {name: 'Bob', age: 35, city: 'Bergen'})")
graph.cypher("""
    MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'})
    CREATE (a)-[:KNOWS]->(b)
""")

# Query — returns a ResultView (lazy; data stays in Rust until accessed)
result = graph.cypher("""
    MATCH (p:Person) WHERE p.age > 30
    RETURN p.name AS name, p.city AS city
    ORDER BY p.age DESC
""")
for row in result:
    print(row['name'], row['city'])

# Or get a pandas DataFrame
df = graph.cypher("MATCH (p:Person) RETURN p.name, p.age ORDER BY p.age", to_df=True)

# Persist to disk and reload
graph.save("my_graph.kgl")
loaded = kglite.load("my_graph.kgl")

Use Cases

RAG & Retrieval Pipelines

Store documents, chunks, and entities as a knowledge graph. Use text_score() for semantic similarity search and Cypher for structured retrieval — combine both for hybrid RAG.

graph.cypher("""
    MATCH (c:Chunk)
    RETURN c.text, text_score(c.embedding, $query_vec) AS score
    ORDER BY score DESC LIMIT 5
""", params={"query_vec": query_embedding})

AI Agent Memory & Tool Use

Give LLM agents a structured, queryable memory. describe() generates a progressive-disclosure schema that agents can reason over, and the included MCP server exposes the graph as a tool.

xml = graph.describe()  # schema for agent context
prompt = f"You have a knowledge graph:\n{xml}\nAnswer using graph.cypher()."

Data Exploration & Analysis

Load CSVs or DataFrames, explore relationships, run graph algorithms (shortest path, centrality, community detection), and export results — all without leaving your notebook.

graph.add_nodes(data=users_df, node_type='User', unique_id_field='user_id', node_title_field='name')
graph.cypher("MATCH path = shortestPath((a:User {name:'Alice'})-[*]-(b:User {name:'Eve'})) RETURN path")

Codebase Analysis

Parse Python and Rust codebases into a knowledge graph with functions, classes, calls, and imports. Search, trace dependencies, and review code structure.

from kglite.code_tree import build
graph = build(".")
graph.cypher("MATCH (f:Function) RETURN f.name, f.file ORDER BY f.name")

Key Features

Feature Description
Cypher queries MATCH, CREATE, SET, DELETE, MERGE, aggregations, ORDER BY, LIMIT, SKIP
Semantic search Vector embeddings + text_score() for similarity ranking
Graph algorithms Shortest path, centrality, community detection, clustering
Spatial Coordinates, WKT geometry, distance and containment queries
Timeseries Time-indexed data with ts_*() Cypher functions
Bulk loading Fluent API (add_nodes / add_connections) for DataFrames
Blueprints Declarative CSV-to-graph loading via JSON config
Import/Export Save/load snapshots, GraphML, CSV export
AI integration describe() introspection, MCP server, agent prompts
Code analysis Parse codebases via tree-sitter (kglite.code_tree)

Documentation

Full docs at kglite.readthedocs.io:

Requirements

Python 3.10+ (CPython) | macOS (ARM/Intel), Linux (x86_64/aarch64), Windows (x86_64) | pandas >= 1.5

License

MIT — see LICENSE for details.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

kglite-0.8.0-cp314-cp314-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.14Windows x86-64

kglite-0.8.0-cp314-cp314-manylinux_2_35_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.35+ x86-64

kglite-0.8.0-cp314-cp314-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

kglite-0.8.0-cp314-cp314-macosx_10_12_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

kglite-0.8.0-cp313-cp313-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.13Windows x86-64

kglite-0.8.0-cp313-cp313-manylinux_2_35_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

kglite-0.8.0-cp313-cp313-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kglite-0.8.0-cp313-cp313-macosx_10_12_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

kglite-0.8.0-cp312-cp312-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.12Windows x86-64

kglite-0.8.0-cp312-cp312-manylinux_2_35_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

kglite-0.8.0-cp312-cp312-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kglite-0.8.0-cp312-cp312-macosx_10_12_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kglite-0.8.0-cp311-cp311-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.11Windows x86-64

kglite-0.8.0-cp311-cp311-manylinux_2_35_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

kglite-0.8.0-cp311-cp311-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kglite-0.8.0-cp311-cp311-macosx_10_12_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kglite-0.8.0-cp310-cp310-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.10Windows x86-64

kglite-0.8.0-cp310-cp310-manylinux_2_35_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

kglite-0.8.0-cp310-cp310-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.8.0-cp310-cp310-macosx_10_12_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file kglite-0.8.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: kglite-0.8.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kglite-0.8.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 a5a68d4b8decf91a3c0865a38db47b2d9a18215cc14c6e91b11a6bc5caff9e64
MD5 17a09c02bc688f2633e4d0afa001dc1b
BLAKE2b-256 77d98efb502080f534cd5e9a246a41ded40774304ad270a7903fc3840d960051

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp314-cp314-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp314-cp314-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 23fa9d38c7037538595ae8586ee88fa296efea12a686fc7022378f88cb714b1b
MD5 4c55ab1dd7a86e787a06516c1adb3364
BLAKE2b-256 e358ab472062919ccef7d9850253124643a82270b6ccb36db1b33cf818cdcf67

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 52365a14b84b5be2d77f4164ceb44cbc2af7cb03e8d98dc769560ffea2eee8d2
MD5 6bfef9bef1be4673663db260668f0b55
BLAKE2b-256 4d810f0a971352f4805e9b07b2de7a3389b948f97820fd240752888b2939d453

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f8db70c09fb9d0189f1783b3e5b4951087a60757e216e33dad684f5ceef0aa68
MD5 75cd265ac7ba604c39d42521c77e6a30
BLAKE2b-256 10c7315a833c69ed4728ff6a2c968ae7e8dab427926e749bc8779789147c2d9c

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.8.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kglite-0.8.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0ef2058bb7c301a4e8beea785ea331b4cdc1fab2e5c29ccd007129558a818fe3
MD5 90aba1f9c7b79d5e2578ac7a8aa5df36
BLAKE2b-256 6f607cd6697122ca60f82f391225f9b85c6b26e4455bc3af3c055c0aa189f0e6

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp313-cp313-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 0f036d3a163be2780b364ee9ec61ca5815050e754a761dc4dc2e9898b5ef91aa
MD5 930c6d4b80b8269d559fb1368f3a8acf
BLAKE2b-256 36c01458dd5718404a2e0543a4a5d13657ff4e791a115b2d053787b914d44be3

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b8c1c04a971c0875149c119fc1bb9adb68e596e164e3dcff6a16f37a298e1bb2
MD5 744294dc8a53bbb935f00d0027fb937e
BLAKE2b-256 38671869833445ae8c8df7ecf33ea36dc330b14f194960b8be3bb1e8dded0a4e

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 43c8456249f6cfbb2accceea0c23f5a17a1234a80b11b885c730753108d61b76
MD5 36969ed66a17f3385ccf83c239dac598
BLAKE2b-256 590856f80a94170ca09b23206a63e0388221ce3d797840e0d5a7169032cd80ef

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: kglite-0.8.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kglite-0.8.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ec3c0608a0a076048edb2ce87cc3ba317d69af26819c2ed403c898f30b4fe1d9
MD5 a77204940907e18898937e418e961120
BLAKE2b-256 ad1698c090d4351f09c72469fa1a5848ae15afe5613d5daa34c52272471b0311

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp312-cp312-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 268e671e27ce111b76aaecdc92264eded868ad79e39d4ad71f6834e578c7a0e7
MD5 4f9975d261ffe091dbcf3f091eb6aa3f
BLAKE2b-256 ddb925ecbff55df5f3cafe643316214af6a2ca8f1e8109322b822b77ca09d22f

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 107f5ef54681ba585f68693f20a2a182b0821048a9d9cb1c759b9b74a4adf79d
MD5 99419135f5d4cf0b9f50e2092ffa5763
BLAKE2b-256 cb2b507c34327449bb8fc935b2aed43df29f2a50f9e5d46eef6b51ad6471799f

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 622b77a2c6035aa137ab1f194bcd5f932d5d73332880f44e2188d131c3efb37c
MD5 0b4afd8bc41d0d78df8c2735f06262fe
BLAKE2b-256 fd2b17c2983580ef6c9e5df2a407517b2038aad9197811f536252ca9729183f0

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: kglite-0.8.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kglite-0.8.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6040c38962879b401e1c4fb430526922532b2a9a9b4a18c8fdfaf1cc8224f5a5
MD5 3d9845d82967b83fb8a3132d8365f1fe
BLAKE2b-256 1a0edc4c6a0c47b132ac8e16b8ad597d0f1b4274d40411de5fcb33bd49adf95b

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp311-cp311-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 ff30f9ca91c0b732ce08c767e2647b12ed3a26e058be29fa1a3970d2323d1eea
MD5 7c010574859eda4397356c8c00e8ca3f
BLAKE2b-256 40505e06f43246aaf290c37b843c4f8a2a4e1febacf3872bc425f5edd5ece8e2

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 75ab37273b1168c5bf0747156a7d91f5a57b85e0a2fdc3f4c5226a67e712a174
MD5 34624bc6bc9ab13000b954b803a5b965
BLAKE2b-256 c2b6ea4c936f368c9dc68eae1f8308c0126d0b497d06477807bb2488dd5d9c8a

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a03bdea03ac37631505bed3f16948adfd7b686918f6b709d42edd39153f07e94
MD5 aecd7df9567ddf3b28d5a9f73eb0e780
BLAKE2b-256 7e1e355f7662a0ea3adbf0f9dac296b1046f96de6a9f0216efe9c49e0b06fb8e

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: kglite-0.8.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kglite-0.8.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cf3b1a9b178c84935a6c72b476f84fa26912a320b711217bb093b3257e23fc85
MD5 e5e40efd09dcd78bd3e9d5f91820006f
BLAKE2b-256 7674716757299872eb1f295cbd383565e4de294b840e7a362531e1a5b90630cf

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp310-cp310-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 fda26a620ba68c04a822e879112c84ba3ff061c9c11cdc328553221ba4c64ee9
MD5 58c876b3938ba80375693c22e43fd133
BLAKE2b-256 b4e51b4721bda34eaa9d1efdb76dca31b5a460581ab38fa763153fb05e4a90e5

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c26d740d822b0fffaebdb7497eb370b18fee4dd05cf6890efdb023835f877c0
MD5 dff3714ea037053aff0bfec880f4f67d
BLAKE2b-256 68704bb58f98c544c14ab55e4318c51125e0ac0aef37c674016cb191ddd10cf8

See more details on using hashes here.

File details

Details for the file kglite-0.8.0-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kglite-0.8.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 71e9fd15d4fbfbac5320969a6351d3e0151948e76a74699096578a8d666046f6
MD5 66b39cfb1fa56e3bd4e067f1944d302c
BLAKE2b-256 0fea5e40542d7be6c2d3ec179f207c24577fcb6d02e0603b113e94b596d0e3d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page