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

Uploaded CPython 3.13Windows x86-64

kglite-0.5.86-cp313-cp313-manylinux_2_35_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

kglite-0.5.86-cp313-cp313-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kglite-0.5.86-cp313-cp313-macosx_10_12_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

kglite-0.5.86-cp312-cp312-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.12Windows x86-64

kglite-0.5.86-cp312-cp312-manylinux_2_35_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

kglite-0.5.86-cp312-cp312-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kglite-0.5.86-cp312-cp312-macosx_10_12_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kglite-0.5.86-cp311-cp311-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.11Windows x86-64

kglite-0.5.86-cp311-cp311-manylinux_2_35_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

kglite-0.5.86-cp311-cp311-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kglite-0.5.86-cp311-cp311-macosx_10_12_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kglite-0.5.86-cp310-cp310-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.10Windows x86-64

kglite-0.5.86-cp310-cp310-manylinux_2_35_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

kglite-0.5.86-cp310-cp310-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.86-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.86-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.5.86-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.1 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.86-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 92fd285ce8272d25792a7275606e6b435a00a3df3caeecbaba84b625bb316b4b
MD5 4c998485845dc9d8c220ef39699227be
BLAKE2b-256 ed85f765135435a43bb300a017c13bf8318496a9f73ed57df923f0563891c321

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 303676bf000ef4b43e694cafd1687e203c66c1f3b24e9855e0feeee1fbfa5cb2
MD5 8ac2906231b52a33e7cb0d84479d4358
BLAKE2b-256 76ff49c8f87979b2d38a9c3523600ec44099b703c7fc8ab515191a8d5f1c720e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c3c251dd0edd84e50369d455334e543a59d13d25f3228647f9eee9d6a0cf5e4
MD5 7585f7f7ae9809acbf60150adfa702a7
BLAKE2b-256 059b6b148aa80a9d3d1dfd5b9093097e575971f4afd6800f9c22efec1ec89294

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dfab00924cadad57eab7c5e56e4b170b5c5f055708302e6b8d73eb21ef032b8d
MD5 0283d5ad9762e69a147c6ca7f71f5a1f
BLAKE2b-256 a57dd149d15bcd4f447238e83bb4c3d76cd3c9525af4f37478e9e3f84972b09f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.86-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.1 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.86-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 475058e75c50e3befd9a5f5726b62584543634a97fa2a74f75678e9c02ce31b1
MD5 18d307940f11f9297c30f056847ad1a0
BLAKE2b-256 170b6fba8b16d532d14cd7cdee68a59520cbd7b227b3aceeafa0c0382a213c2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 bcf27e9e95dae8a0a59daa69e50bd231df2658152650fe2bc8b197b2034149f1
MD5 909dbaf57b57674120d267993dd45ed8
BLAKE2b-256 18b13327caddd5b6f73d3a8afb8c1748d08ee3c055077adc204e4cff99a0dad6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 582d453dac481af043b6d9322720c5ae84f49b750dd50c9a4709e05a67f145c9
MD5 2193dd63e5ee2b0cb51f36ac00bf2a32
BLAKE2b-256 54d63f33addafeccc1562531696a638f123b20bdd06a2cb321bcb342f10ec56e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0d249bb3785fb6f2451c562811cb13bf4508aceb963a59decd2cf577652272f0
MD5 75c0bb5e4ddfe535c6eed85b6706b617
BLAKE2b-256 7896e049d71d3aec7c2dd19c4631bd20bc8eb32dc0b0a6ada4efda70e56e0208

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.86-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.1 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.86-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d0edcb4d3a2b23e3b7a199090773c3099127c5ea0137dd13c8fa47697fafc959
MD5 736c97deaa161ac06c4cc601add03950
BLAKE2b-256 1071d06ea2582fdacc31c5658b3355fdfa118bea3d8e4a705b2c639d8417771b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 010303fe51ec47cf461c740e897dbcc19cb70801bc7f13cc6cf28e637bd166c4
MD5 00c5c4e592a6cb18d02839d07ac22253
BLAKE2b-256 89963bd8fed607b0ec92f7c0e11e904f84f201f8cb0eb7d80c67ce5cf858351e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 45627a4b3f61161f350313766dc413ec67b1439ef38e44781c25f0bc19be9600
MD5 f1d0121c0b78dd7900b06721ebcb9842
BLAKE2b-256 ac29ad8cd9c99f36f4f44bf058883f3af7926d3824fb9be1b3b28089578df368

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 678c62595a08efd396a7f5112ee6a5d10b80fc88b9413a098fcf56ddeae85ec1
MD5 eb089e99f1a37fb5de1db75a76bfd3e7
BLAKE2b-256 ae4a99ab99fc37205ecd31a85d38e93a393c0bbb203188cf40ab7c009a2e1afa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.86-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.1 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.86-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d65c070e55284efc5a70a42ecbbc801a5f44bb5bd0be06c9e0388d458ebafb49
MD5 ee72291142d748c4b947269b7872d533
BLAKE2b-256 b06f6fad0d120772fab7db3a785fa4153c228502a766db7fad8063da751f89bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 1ac3cb4e92892ac7a272f7481a8e654d821eb7d2a190569654cb4525994ef354
MD5 981ed112e685d85bc7d22aaaa1f9e0bd
BLAKE2b-256 e00e428b4d5c2607ab0de7af962ea903cd3b60b8daa08952d4c05ca9fb2f563a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ca78abcae7f20c44eabce69291fc5c843059d3c845d55060cc3328d311d3203d
MD5 7a1a4d99cb6c5dd644ef8f25359a3c7c
BLAKE2b-256 cf0e08e6c93b4f51f5cde0bd94d13debc9d48d163c2017b4e46e29cdd52c604f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.86-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c17f58362e410a96ecb30dc882f24e8e665fda6ac20eaa7b08a899412e3b456b
MD5 edf30135a32945157547d62b6fc30237
BLAKE2b-256 4052a4772faa941bd96f6f0c73acc05875af51a4adc967e930ef978666496382

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