Skip to main content

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

Project description

KGLite

PyPI version Python versions License: MIT

A knowledge graph that runs inside your Python process. Load data, query with Cypher, do semantic search — no server, no setup, no infrastructure.

Two APIs: Use Cypher for querying, mutations, and semantic search. Use the fluent API (add_nodes / add_connections) for bulk-loading DataFrames. Most agent and application code only needs cypher().

Embedded, in-process No server, no network; import and go
In-memory Persistence via save()/load() snapshots
Cypher subset Querying + mutations + text_score() for semantic search
Single-label nodes Each node has exactly one type
Fluent bulk loading Import DataFrames with add_nodes() / add_connections()

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

pip install kglite

Quick Start — Cypher guide

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")

Bulk Loading from DataFrames — docs

import pandas as pd

users_df = pd.DataFrame({
    'user_id': [1001, 1002, 1003],
    'name': ['Alice', 'Bob', 'Charlie'],
    'age': [28, 35, 42]
})
graph.add_nodes(data=users_df, node_type='User', unique_id_field='user_id', node_title_field='name')

Blueprint Loading (CSV → Graph) — docs

import kglite

# Define a blueprint.json mapping CSVs to nodes and connections:
# {
#   "settings": {"root": "./data"},
#   "nodes": {
#     "Person": {
#       "csv": "persons.csv", "pk": "person_id", "title": "name",
#       "properties": {"age": "int", "city": "string"},
#       "connections": {
#         "junction_edges": {
#           "KNOWS": {"csv": "knows.csv", "source_fk": "person_id",
#                     "target": "Person", "target_fk": "friend_id"}
#         }
#       }
#     }
#   }
# }

graph = kglite.from_blueprint("blueprint.json")

Code Review (Parse a Codebase) — docs

from kglite.code_tree import build

graph = build(".")  # auto-detects pyproject.toml / Cargo.toml

# Find the most-called functions
graph.cypher("""
    MATCH (caller:Function)-[:CALLS]->(f:Function)
    RETURN f.name AS function, count(caller) AS callers
    ORDER BY callers DESC LIMIT 10
""")

# Explore code
graph.find("execute")              # search by name
graph.source("execute_query")      # read source code
graph.context("KnowledgeGraph")    # see struct with methods

AI Agent Integration — docs

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

Documentation

Full documentation is available at kglite.readthedocs.io.

Topic Description
Getting Started Installation, quick start, DataFrame loading
Core Concepts Nodes, relationships, selections, return types
Cypher Guide Queries, mutations, transactions, parameters
Cypher Reference Full reference for every clause and function
Data Loading Fluent API, conflict handling, batch updates
Blueprints Declarative CSV-to-graph loading via JSON
Querying Filtering, traversal, schema introspection
Fluent API Reference Full reference for every fluent method
Semantic Search Embeddings, vector search, text_score()
AI Agents MCP server, describe(), agent prompts
Spatial Coordinates, geometry, distance, containment
Timeseries Time-indexed data, ts_*() Cypher functions
Graph Algorithms Shortest path, centrality, community detection, clustering
Import & Export Save/load, GraphML, CSV, indexes, performance
Code Tree Parse codebases into knowledge graphs
API Reference Auto-generated from type stubs

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.5.82-cp313-cp313-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.13Windows x86-64

kglite-0.5.82-cp313-cp313-manylinux_2_35_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

kglite-0.5.82-cp313-cp313-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kglite-0.5.82-cp313-cp313-macosx_10_12_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

kglite-0.5.82-cp312-cp312-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.12Windows x86-64

kglite-0.5.82-cp312-cp312-manylinux_2_35_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

kglite-0.5.82-cp312-cp312-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kglite-0.5.82-cp312-cp312-macosx_10_12_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kglite-0.5.82-cp311-cp311-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.11Windows x86-64

kglite-0.5.82-cp311-cp311-manylinux_2_35_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

kglite-0.5.82-cp311-cp311-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kglite-0.5.82-cp311-cp311-macosx_10_12_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kglite-0.5.82-cp310-cp310-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.10Windows x86-64

kglite-0.5.82-cp310-cp310-manylinux_2_35_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

kglite-0.5.82-cp310-cp310-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.82-cp310-cp310-macosx_10_12_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for kglite-0.5.82-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 bab37bc10b5a03bca7731ca86a54db45d06305d4ded278814691f142809e372a
MD5 b76fe4e2c275e575fa560789301983fd
BLAKE2b-256 ffca0b6e7353d7b4438284dc46a872f8c488d498f36348b0c0a3448256639898

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 660cee07f3d543f74177cf31df82e05e037004089eaef7f40ac0bf50dd9f22af
MD5 26f885f30aba3f13b00f05b6a5b98d40
BLAKE2b-256 62dc88b0752774471535e461a6dd600dd5345769536f1f3900c53a8c50d7e0c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9bdccbd778d2a794a2ecdf3e42fefc39994855ebb850f65cf0c89331630c7ab4
MD5 21ff9fde864617074be10fc266172c97
BLAKE2b-256 6d494f9a5f7eaa1a5b5ad894625ca263475a239a2e23c111aeddf5c7e57a610e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f4cb76527b5ce8a20f1d72ebcadbfdb7f2c94cc373a9f43aabe866a6ca772065
MD5 765aca478b1ee97900dd15b77502bb54
BLAKE2b-256 5fffda39dfefe590d6f9e243fcbfbfc0251799e31ef04e00885b3c1eb91e7746

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for kglite-0.5.82-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 27af26ded4376dc5852f8568638423b231f59fe9d3f728cea2d2c572150daf26
MD5 a49ecf03324c53daf30d7085a77da817
BLAKE2b-256 126e8c357190bf6d50aceb87102d7ca819e4ba331e00c2263f7199b6b2778438

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 3716eb6e2a9ab54a1b41f5a17f6eeb44b0f125140016a5f1736716334e706aec
MD5 cb5e10fa674aac44a71dd8e345b45b43
BLAKE2b-256 f0c08af45701ed698593e0c1b765bb9730485b03f18b4e39221b63376a50bbd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1dd3187319b24ab7a7d592b1a42dbb7549bd30bd4edc8b5c036c5e2d4436baae
MD5 a0e109307c2abc34a5d15f4c0ef0a797
BLAKE2b-256 76351183fc80b5ed2b04fab23f10add8f1518e5f6d9809543a290362976299cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9de4f75b7da3bc4d7bb72891347eb61c4311106b65a2c5790b9c856cedfda574
MD5 32cad08f566b46b83ac6959c800ac9f7
BLAKE2b-256 b2a738e679a93738f721be12a95a27477eb9b57d3de193124e853be682200c0c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for kglite-0.5.82-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8048867cfa60803d6679a9c03a01c040f0465a606c8b2ab11906f85e9bdde433
MD5 c9cfa08f4aa2d7bac3e6cc1191fb0f9b
BLAKE2b-256 30ae6aae52f3cc93eefb712221018b3ad480696aa737364487e4e6e6162b3dc1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 7883c1e39a05822c2674b422cc4a425c867e339039a9529b79683cf809503228
MD5 4b2779539cd2dfb001e7a634b3410d02
BLAKE2b-256 fc7006722e378bd2b5ccda2c97f9f7af2ae20810b597f7cbfa210a0ed9c151ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3a39fef740e59b365a75588e730ba6c2f4c26b8032ababbd22a630dcc51ec3f4
MD5 d987f3f999c9d686d47360e9580bd93d
BLAKE2b-256 ac1a29902093488961032c86f33f2c339e09992628d15835eee3b58dc182bf14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f459336c528b0b662551c445793c96397ea68d2725689c6476a5188ed2bb401b
MD5 0e6e866889a2a7e9f7078809e93dea13
BLAKE2b-256 0ffa03e07da8e067bdb700dc54d74a262d1c5da8ee05d2071ed54f3c941dfba9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for kglite-0.5.82-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e83659e125921e0f4c147fca047e066e4b1fed1a6215ba6329463b52e519c955
MD5 34fd5027ca5048916bfdd67c239f22cb
BLAKE2b-256 5a25328cc79cff4b161446edfad64339d28c5b9d4dbd0123b111df0c98b6954d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 79f9f189ac8dcb0b69089aae210ab72d3de480bafbce7efed79d24f7d9caefed
MD5 c109c6ac853e65ca1f52c1981a637dd9
BLAKE2b-256 caf4edd9cae335111237f03f5cf26e033e742ffa481718eeb16a50af3bfeb879

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e9860dad58cc1ffca6006dc3f17ccd3d583d5da5f7bde8f935fa61890088d5c8
MD5 ba5149d6273c702f21f2e4ee4ec71c2b
BLAKE2b-256 57ca7e5472076d9a6ebf85b26274d15fd6e94adadf9dd7c139b88d2ef3d20a1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.82-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ed5937a69caae7deeecc3f9f58f3eb887d9767a70a5ba80fa1e3dba55923ae7d
MD5 3802bc578dbd270b2d4abc948c927c4e
BLAKE2b-256 96da82fd951f0ba8f8aa3b5fb93d1aad67b50bdaf2b6866150658f7e11637b38

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