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

Uploaded CPython 3.13Windows x86-64

kglite-0.5.81-cp313-cp313-manylinux_2_35_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

kglite-0.5.81-cp313-cp313-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kglite-0.5.81-cp313-cp313-macosx_10_12_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

kglite-0.5.81-cp312-cp312-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.12Windows x86-64

kglite-0.5.81-cp312-cp312-manylinux_2_35_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

kglite-0.5.81-cp312-cp312-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kglite-0.5.81-cp312-cp312-macosx_10_12_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kglite-0.5.81-cp311-cp311-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.11Windows x86-64

kglite-0.5.81-cp311-cp311-manylinux_2_35_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

kglite-0.5.81-cp311-cp311-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kglite-0.5.81-cp311-cp311-macosx_10_12_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kglite-0.5.81-cp310-cp310-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.10Windows x86-64

kglite-0.5.81-cp310-cp310-manylinux_2_35_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

kglite-0.5.81-cp310-cp310-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.81-cp310-cp310-macosx_10_12_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: kglite-0.5.81-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.8 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.81-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3d513b75bd81ad2db0ed7f82c7578b85b8da9fa81b16a4452cd58efbe0ba33c2
MD5 19652a8eb10cc85f433777955a52b523
BLAKE2b-256 200a0065424db47521ced305be93fefa43e9d1b89ab26b5403969eb45fdf7f6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 be8cc898d5350e0775c6cfcfaa47e03a141ac7f68bab9c8f762c739be98576a5
MD5 6eea8d876ea40606e30ce1faf14c4ad4
BLAKE2b-256 48ab389497aafbd39372eb7b9b796f4e73da8534fd54e79c9090b09cd312af1d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bfd20d51bcabf59623d723e7a459edccedabb2e4581917760e9f50902ff564ed
MD5 246e070263ef0757ffa6dbfdc1d001cb
BLAKE2b-256 ffc859d20f2ff9e1c7f2b6ecc570bf1daa644da8ef329dee373637e51f16813e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7103a2f17e9a4e50b341504578997eea4c4f04e50a604f9d4f3ecdf22772334e
MD5 49ea145d4cd3aacbd6bbb3973a4b6eb8
BLAKE2b-256 e1455a7dbab956809c54283215f69ba6d47b2871ccf98e7963a60a29c4b3ccdb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.81-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.8 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.81-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7e57eac99377c2af8d603334e212655e7776459351facdb148b99d8ed6d3d9e1
MD5 511cc1ea17488be412f267541969ef7f
BLAKE2b-256 e00a9ecfd96cce793f53fb2f05dc27cd6c6e790c7b357c1550eacdb8162f6001

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 2262567d17ba47e71fa5c2baca952f5084c850b632b63f18063138b85e13137a
MD5 145161709925bcee4e9cab61796ede1b
BLAKE2b-256 5aad13b5e154cde3a2d2803da796e30c84255622aaa22728ce642d8dcf61b261

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f6c99f97b532088f900ea504c948ea2473106f70d5c248c3b620fd991ead6db
MD5 7d69654bcfb1068162adf5e373880f43
BLAKE2b-256 112fbd54d334a87f238ec5b10b9181b1d20bc2fc5f05b589fa13f850ab4c7772

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5f3a63cda705ae0e4ebced92858b39c24e0f657efe2dcfb5b41c2ff91ce07e1c
MD5 668e1f68a7182c7593d7a022cc02fa19
BLAKE2b-256 0838643e6c4e9efb9317b59ddac764f4c01635f5e8104cb45ca33e31321a75b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.81-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.8 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.81-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7da19b22bac4a294ca51211f4868e0d9656e469713a9d5fac89e14c5ed56411c
MD5 4c5e325731e260f5c98aafe3ff9fbe86
BLAKE2b-256 c7ed8756606db45449ddbe5533b874537f6013e1a4577475f183fceb29e9dafb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 f31ed0bb9dd43364cb6be6e80af941b46bd119c02cfdc19127b88bad9d5d5b73
MD5 17c0a322d7f437910e3788e9c25f08db
BLAKE2b-256 86b9aefa7dd1913cb89d2f4a57eca07ddd780a20827e75b8f8c86237bcde70f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cf4fa7c9c06d9cf0b8e495219ea4c53bd7fcd07b3899d15eca6f46020c4e3161
MD5 5abb7275eb48a25f1abdd43281a4e4d1
BLAKE2b-256 eee3ae301f29a3577bbc848b4b1f83f5dbed7ea71efcf2a7babe6c310737ff3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2f501dc84cd440d6d1def1dfef474f9c2c8ef45b04a5bde0103be92ea052d75e
MD5 821b411f0ebdff8ccef8d9843087eb88
BLAKE2b-256 b019377aa9e66e3ac4b456efb6d4bb9f5bfb188f6703beb276000f62b962882a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.81-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.8 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.81-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 40aac8b93f8acd5d0de5e9d935054f9d73c8f03eacc3bc01facc1915a9806271
MD5 48d8f83710e5c009df18a72af88bba9a
BLAKE2b-256 f956413c367d9557333389a4ee3b6103ad59c2cca9c85acea2984fb53a5d51bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 1fbcd9f6f8b0c78b78c209d100937363743e4c20bc89cf8f3025defcf9677d5c
MD5 277083b1922b3c2a8cd213b080eccedb
BLAKE2b-256 9c4fbcd0577310847bdc145957f6a9b575126b513ff546b4acb837f6c6dfae2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c60ef91541d120f49fefca42c47f359cfa02556258c5444ba725361796792fc5
MD5 ea5806bfeab05f8ac9c7b3d75b9384e5
BLAKE2b-256 3f36a6c58c2b10f6ad60fa2588a29040026f6c47ca3b6a803f8d5802d0c02268

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.81-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b77cbbf2bd38c0924ca7dbd33416af57e64a9606854ddc3c20069a2ad39a3a57
MD5 9f3c3a0f73e678fab76ead560cdab0a7
BLAKE2b-256 8394270bf0b06d4adedb150a4af15fbfce5e34e1b58cef04a137fb615f3e0666

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