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.7.17-cp314-cp314-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14manylinux: glibc 2.35+ x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.12+ x86-64

kglite-0.7.17-cp313-cp313-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

kglite-0.7.17-cp312-cp312-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

kglite-0.7.17-cp311-cp311-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

kglite-0.7.17-cp310-cp310-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.7.17-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.7.17-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: kglite-0.7.17-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 3.7 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.7.17-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 f97cfcee4466903cd364bba80d12ce6324ecf224ea7680604b6c88e7c35dcb8a
MD5 a6c46ded680f21c1b7a3ab7a4420a960
BLAKE2b-256 affb925cb2fc85c4c8ebb7b1b8599222c2a294a3de1c684ced91f4e9a7ee17cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp314-cp314-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 7e98d3a2854d38f277394ac6b56da1f738d021bbdadc380193644f7e2efcea38
MD5 0ebe57d599a65254bb4b6a07f2e9e736
BLAKE2b-256 6670552269c66736b40470b22477dcc98cffef1d04f69adcef94293f7d4aa12f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9319364651bdc34ceb9bfeb0e000269082a02835d08cf642f3e0fd46524d6abf
MD5 7278c1612e2962fba8d528ab337c88e9
BLAKE2b-256 6d13b3443c53161b656d05d62a8dbf970de38359a3755688241886ec2998dc70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 caedf5f39264d30039e49896e617c4eebae7ca4d47c95417105ae2e73a6d15c5
MD5 901881ab2256f8e130ae9d30253ae7cc
BLAKE2b-256 32bf94af8b5e27dd5692cef01a09b354bbdf8dbec8055d7b68fc46c39c0baef2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.7.17-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.7 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.7.17-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 72c8c933bb74ba1ee364adfbb916662038f1247cc165eae1fff858154f7f81a3
MD5 9fd291fb2cb81110a1992ca5455a9f81
BLAKE2b-256 9d6c3a69bb2aac8c7e1ff6ea8e03e6da59a1f376013a1ccead655143201e69cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 4ea81e5a105179e6e405761b3ca887509b120420bc512a7668c7f97517ae0fcd
MD5 9480d3a05b1260f8c14fe53c80062023
BLAKE2b-256 e45889bdf723461799af0f3851fd371a23fa840f787edb508b810c697e24ec61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8c9d792f2ce14b3b0f18a78360051b1c9d8e9583c9ebab685181291b8ec2308
MD5 29cfb0d43fbaa877ed951002a05811dc
BLAKE2b-256 1f570a1be62ed05eac449ce3fa4991ad35da1df361731899252a18b2fe661452

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 027829dc52f53e1e123cf26cf0f6e5a0a703d3a050a3e1d9cc1923571357c988
MD5 d99f1aec019f915ae4f1073a94fb7e74
BLAKE2b-256 69b86fc10e6639b29e0002abaeb00d8ed1adf6bddd12b5c1996b714f537f6a90

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.7.17-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.7 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.7.17-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5fa6cccd93f064c31e990c5a6e214a5c44a0954df5f02d73630f3f9e2ab0cdea
MD5 6da94b757d3f558e9ad87f517e3c9326
BLAKE2b-256 449f7554a4fb9304b46b25f17ab653b98b4997013cca4523e0423f86a8cd5a5e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 26608eeca2cb1c524754c025f766e5437ee54aae933730e6648fbefea3301864
MD5 c81511c681162f7be7b9261d2db51213
BLAKE2b-256 42fe697541709b74c1d67758de5c14bfc38b45e4071360ae09d887c53af19927

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 555c4ba5986099493e516cc11fa7ec2e617ba55009d63a886405c4f4c07392b2
MD5 6a8081bcf0c43efce122244a63a17988
BLAKE2b-256 932fda6e1b5614ec9d0ef018bdc0fa6c2c4a1a1a4ede53b56b5d2b3456037477

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 68241f9aa3e2f8c7fe97b4c5c2c467026ac1780f7b31e5746f6b2c5ffc7a26a0
MD5 3463cdaea5c9677d591656f16719e0df
BLAKE2b-256 73b95867107878bae40a78894e9e6a2ce403bbea2c85ac49a2aff9f1f3bc9bb1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.7.17-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.7 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.7.17-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d7767630fcdf8a680391c1b2c04ecb54166cbd93d9ec979a1e9006ad988f99cd
MD5 9bd929c47599e928e30681264eedf204
BLAKE2b-256 b0a5cce43089b0b8da73ff98cbbb18483edb148ce2d65668cf67ed86d23c7bdb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 2393ee32ee61bf2d1f1b93d92de6e0377c4b679017c191b1173c71c0c81a8c27
MD5 3e6a2e73650c72b1d1e4c33d425ca7e1
BLAKE2b-256 1146514b0eff8f3043cbc61e375cf34afc3360a18e825b08f74ad5642630f5a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0181a28edafe619ed82aa28508c475d7ec456854c4c91e48da66fca7465f01cb
MD5 350f8da8c7630d7595daada927723f7d
BLAKE2b-256 edbd046ec2d2b4832cb9b7cd6dc506683fca2e5fa84f8535e6b2b90a1133f699

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e47505e0a21786b90474fc950e37e02291bc36a59c11dc6fb6fe85241c5b47bb
MD5 9bf6e29c52b2d6a5bb5bdde6ab144744
BLAKE2b-256 6632ab2b1f88649fdddb118746fc5c779cdd4c0817f883018738793e3d0c86c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.7.17-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.7 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.7.17-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 51a58200eac2cfa80a0548856e7e764a19992b0610610480e965af13eda7e2c5
MD5 bfd72c334575d806ab936533f89d8b88
BLAKE2b-256 5820b03e139ba3cec207149f0ae3c89c741e27253961667cf9b67dbc86953323

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 ccf46d51bbb6bdfd98ad76a81960b3bd9e39b604de7055449d949edb65e38db4
MD5 e8377bea497573d052279b4519a78e97
BLAKE2b-256 a470896d20fcac38317ce66685e1c552d321bab2ead7efb05d228559d8915cef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 05222ad1c99d71cbe98fd5f5d8ef33850adc7a1df615baa1664c4fedf77e7e80
MD5 2430bda0c847c74dd1f31b2a46dd6c1f
BLAKE2b-256 681d22a0d52a42c557bbfb076e7791e1fe83ca788d4b875bdae2ea0d165159c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.7.17-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c118b4b4dd9a47732e500149a137e32b336c37a2227c6ee58101c7d911b85c1b
MD5 f0c9fbc3fdfc076185d84b2dad182068
BLAKE2b-256 7b8264ebe0ae1e5f5975c420a4ce65d671d4d1918f85528d6e385ac978b90252

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