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

Uploaded CPython 3.13Windows x86-64

kglite-0.5.76-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.76-cp313-cp313-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

kglite-0.5.76-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.76-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

kglite-0.5.76-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.76-cp311-cp311-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

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

Uploaded CPython 3.10Windows x86-64

kglite-0.5.76-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.76-cp310-cp310-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.76-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.76-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.5.76-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.76-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3f45eae2a5ce40a2f66a3e556766f94ec92cf470ff5418f92b5622d33b8e8eab
MD5 9f80418e4edcbccbb9cae3d6dbb15f9a
BLAKE2b-256 8d445b256ca2ce9b86b8aaa0164528beb8407019170bf39ab901cbe905dbe08d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 719adb81f9cd5f493cf0ef3452cd260655dde3d2c0179fecfcef9de61deb3e06
MD5 4902df104c420afb11ddf6549eef9497
BLAKE2b-256 2d28cbacb59e17bf7c7eae57bbdb184a491ab05c6b0707447fa43d21a4dce311

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ffb88e4c05af536688207e3b38f4a2e50e8ad46df5cf82b4b23338a8114338b
MD5 e69f79c5d0eb756f4b184faf5796f7c3
BLAKE2b-256 ac199924dc082d6be83ccbe602dc447a0b78539829c130ded3bea37f72efe15f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d69d0bc08b2b76236764e4dc94255dd779f042bbe49782872520307c9f4ac01e
MD5 c66f11cd6688fa44eadde3b94c2f687f
BLAKE2b-256 83c7925b0909357cd3846a7b299ae8de19278c497ef20737ca9ccc531e7b5b24

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.76-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.76-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4b24ede72e0c68759bf67026ecf152ca3dfa7bae51855c6e3cb3cbce01efc855
MD5 6b3ca4cb5bf793b6c3c889fd6a5d789d
BLAKE2b-256 99c910aa133aba8fc335d1c995eca65e6fbdcd055cfead9a9bb6ddb8a2c72088

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 ad500e91fcf0716bd32275a5cc6385402aee72de2d747af1765c2b53cdc0371a
MD5 2bdfd11f27b89deea2f83eefd7cfbb4d
BLAKE2b-256 310eea0ec51e66857f5af90f2f77af2bf54c0b81180ca824853e5b27f9d2b71a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea890f86ed9d07c9a2053c926466308c6b5a8e1c56f127a1d8bd787bacff1404
MD5 58283648f548e4be8ab1ae8fdee2bb5a
BLAKE2b-256 f0c4bb2a528b677b8c25b216083211aa5d0f7739e4e03417138a05228905878b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 17ab63ee46816262f993ae26e55e44499e79069110882896f562b63b5ba07251
MD5 d06e9ccbb0b6c588819b4ab92713031a
BLAKE2b-256 c5a0b397c944f055d3dfe6cf2b26e9a9870204bb0aa34a0f9d138a8e1c500911

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.76-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.76-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9a9daf21ec75f51524eeaee29796c2d5e730bb92fa01c8c187f12a8e2404d1c8
MD5 9da303ccf5f3f9e07fcd9366e1b7817f
BLAKE2b-256 4f0583955f77c9a0ccdb301e6309e97bda235e13697beefc5335bd253e2827cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 6ae4a892b0e9aaf95ff4d3743ce389d09050d05dd3fcea2a64cf484b8db76344
MD5 500c1ea51faa80005ec57e08c5577457
BLAKE2b-256 0bcc7663140d0f315471cf0856a990088de703f0e66aa775403ba42afa04ae06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c9351eda4141ec1bc54cd17b5f580733c92d0fbfd9500460a18d6d53fed328b3
MD5 0fb4987cfac41a400ff118137c1f8d4a
BLAKE2b-256 fea91bb6ab8274a028b00d2a4476a0960cfa769081382ad6cab0a40a5625b58c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 26828855ac720b2e749211d82c30ed344a423e9cc83efa0b08fb2177cfa41f55
MD5 92e0ce48d403785f188ca163d3c02cc7
BLAKE2b-256 cf4fdbe42835789c4c473a1f96da293588256a2517d3c75fb1a5d6b5c26eb588

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.76-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.76-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c29b7125abde7031bc479b11af5ba50490acd871cdb329554ee1854e672bb262
MD5 b61c454b2a0d7a86934862b00b8a8231
BLAKE2b-256 78547f888629f863c4ff1717cdd24cb4e3cc8bdd53fb5db844df0f8e1ad6386c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 dcdb837f7312d067b2bc26de5486caf8d8045d50bcf55ebc6ea529cdbc1bce63
MD5 658ef365752d7f6cc9e84c51bc93cdce
BLAKE2b-256 f467d7fc0bb79b21a8d6db8ff3e0f741d549ad3d07651a02681f8f329303009b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4d30df85aaeb7baaa21d238e117eb6b0cd1020c1d5d85cd0422861a83b10ab3c
MD5 1154c2817e2a8e7b000023a7affceb36
BLAKE2b-256 9b2028a7ae8892a6ff717fff4c42cf8265832f75cfb5687dea5ffb56f5ca867d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.76-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4cfec45312483cb251fc72cd2b70150ae26af427ff60149d74c13907cdd31655
MD5 9dedb00ed732268688e856a76c302a5d
BLAKE2b-256 97824d7a29effd009f5b8bd8d1e8f58e34b760c0e246dfd06860bba7cf8a9b13

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