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

Uploaded CPython 3.13Windows x86-64

kglite-0.5.75-cp313-cp313-manylinux_2_35_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

kglite-0.5.75-cp313-cp313-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kglite-0.5.75-cp313-cp313-macosx_10_12_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

kglite-0.5.75-cp312-cp312-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.12Windows x86-64

kglite-0.5.75-cp312-cp312-manylinux_2_35_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

kglite-0.5.75-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kglite-0.5.75-cp312-cp312-macosx_10_12_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kglite-0.5.75-cp311-cp311-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.11Windows x86-64

kglite-0.5.75-cp311-cp311-manylinux_2_35_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

kglite-0.5.75-cp311-cp311-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kglite-0.5.75-cp311-cp311-macosx_10_12_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kglite-0.5.75-cp310-cp310-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.10Windows x86-64

kglite-0.5.75-cp310-cp310-manylinux_2_35_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

kglite-0.5.75-cp310-cp310-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.75-cp310-cp310-macosx_10_12_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: kglite-0.5.75-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.7 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.75-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9bb8496b2c713a49a75861501a5a1ca8ce09c0f08f328bdc94f705449e7c4648
MD5 e51414bd9dd1486a24530e69c4cbd638
BLAKE2b-256 f48ff6ee89361c9a1e344fbcaa5ac3142d5eeb87657b41f38663764401c10b42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 cf4d7d9f836abd6cd114b15d6d56d5a73781e7d7e0b356a061baa410465a9b00
MD5 c24d6cfd3d474ef3b139423df41803c1
BLAKE2b-256 befd37fe444381ded0f7b4615ecf9aaf85e0524bcb2fe253e48e2b440bef8e7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a3242974b744027f2a23ca2dc3946750e4adee83079236528c64864f3d0aa1e3
MD5 222f291216debb2c8f71af9cc020c1e6
BLAKE2b-256 ca5e322a0e5053e22d3595648d899085336b2dd61769d8b7b932f70d6d3c7bc1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c6a987e2d8e55963f42cbf63ca3a68a3a28fd39fc03532b57fe8c4a9dc906a13
MD5 e5da4633ea44a3223b0918b9e550408d
BLAKE2b-256 fb7864c13e8fba200cc46216191b5929f139e7fa42e4de0daa2c603e5323bd61

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.75-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.7 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.75-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fdf7099dfcf09816153ec696257b0f15add4816f8b5b9201ed15c9b0d7ce5801
MD5 6946d50c24f531773cb20d591f79dfe2
BLAKE2b-256 c387d0c4c2e406c74a68e97918cc42bc3836514dc6282501b6da71b28caffc97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 fb9943bd559cbc2b8b2b1b9bb1fd6db5287d1e60947c5f035a943b5dc9da2a4d
MD5 5147a657638eee9c13adf0c75545da44
BLAKE2b-256 b8786cbdf6d9c92a7e8c1b74db432a25579104fb9baf8fe68331378a5c7f4510

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9fede8e9bfbcea23b5742b2c1dce8317a2e96f9ce28da62e223fe73ab4e3938f
MD5 88bc93b11fdab076aef63cbe60045f84
BLAKE2b-256 8834fbf102dcd0bf0e2d85f1c0594ddf3295eab8a104272c877db0823291274d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e5b7e6fa012ee9b238ac72e2c0dc568a3b032bf7571f38e4781a03f363168f79
MD5 86e67f771292c87b37684b5234fcfab2
BLAKE2b-256 f9528d2575c2f8bb7a6eac09a32d67c0e4ab932e8c7039ed0e7b5253fbf5a087

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.75-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.7 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.75-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 08a6f6a995830566fbad6aad4cee73514ad911723037b62c1e7cfebc48403721
MD5 7de6a5c0e84a5e0ff20849c46d3b31ca
BLAKE2b-256 4d1e659f200bdba4aab8d8a9c59b60439d5f55edaf7abdd6c2b74f3ec3a8d0f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 07d67d00741c08003cf8698aab14e7a009e900c9643c8f3b3f34ac4d3f668f37
MD5 0e2cfb9c6f0ca990852b6ef4a5ee03a0
BLAKE2b-256 3a30b871d0d239684834312c062a14716f43cdf8ae4705d394ffcaf366ff784b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 61f7e6e133e7710b8d07c22ee418467b1661339b583ece199be1cd656d2db90d
MD5 394dac377c5912e3e300668f09a4961e
BLAKE2b-256 968d7f53ad559e7f09c4cde28bafe1cf6e1246a5cb5bd57e0fb06de5e677d610

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4310a985e9ef95761b4fbc0dd5ea38b413e5c9f0c78ca7b2b25b23201204602f
MD5 c777fd4771b8b9178d2d8bb4b22a6630
BLAKE2b-256 16db0d8fe54f628e37e1e2b57824596a870ecbee8de0005846689213d1c7a85b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.75-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.7 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.75-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 26783c412fa45948387438b7714bb6c26bb235fc7e747a4bbba0d76021347af6
MD5 0569882675aeec43ca913e50205fec2a
BLAKE2b-256 5bcb8d3985f4f38e60796e1ee81790cefcf00eec89ef59985b38c8fe9a0c5340

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 e63fc255f00a2282db1027c09656d4ca932fb2ffd334cf9c819f302fa7d7e9f9
MD5 c1bbb666ad31b94f816825210b1fd3a4
BLAKE2b-256 f203076448824e79867e6c4295e634691f7814617b286398d7b227987e6efa73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 36cbb2c53012f58be9fbaa971c87275a4b905093aea9be75bdce34c1623e73ee
MD5 e17a30edeb62621dcf912a7941020be8
BLAKE2b-256 519e9a637c17873605b8d8268f66930693f0e50784559bef47c190a89e133ca4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.75-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a63e123b674b2a9d04953f433e662803ae0b18836266dcbaac03ed1b0c7f847d
MD5 ca2d8c9d45450846eb3ccc4ecc94cdba
BLAKE2b-256 7592f89e5b2b0e78cdc3a8f8121e6e4bbe3b6ff8b899b8b1d0a97a91522637dc

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