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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.77-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.77-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.5.77-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.77-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2f836184ee4e22b6a9839a11200863dd28263fb091b628f4ef047c071e310ec2
MD5 9444678b8e68d615ff881fa440b6b3c9
BLAKE2b-256 343ce157fe10ea616332c06df35a4fcb2b7ecefcadcb8bf96e74a8a69bfce84b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 18d3b7aa952431aed512ef89f8b4eaf1feb85042a7b84641f989fa115de27ab7
MD5 41068e0f9039fad79a5e41a2264a2f70
BLAKE2b-256 3b05e71077827de8072f91f06ec3b1e1d36d1e0891d0a48a8583879e1d39c34c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d779d44b7b8767b5ef0febff3e34b2b1459dec2219518d42e07459e08d2f4c5f
MD5 17d9d5e68422857ccddf84d08ff002c7
BLAKE2b-256 520b051bd75f134ad542eef912a4508dc39f494ebb7c16c8f4fe361dcd7619f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a4a4474dcc00c616b04988d704c2dcffbc2b600c9b2d15fdcaac533e4c561e4a
MD5 0961016cfc033f84cb4ac1c459f7222a
BLAKE2b-256 2f2ca4aa90810ab1cdfb3b23c345c87bee6d5829c8555d4a58ed896dfc0d85ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.77-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.77-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bbed5f560bb2d0aa974f5ff62c720b700f5bb1de0f6e2956d823e3a3253ba9a5
MD5 078d8d8388a993ba75d1ed328a02cef8
BLAKE2b-256 dd2a7e8c9c841586325fd28abe21a577342272044a63b6ac0eb7a83becfa36eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 a899a69ee135f5a0b947017a302837c696443e751fd80775a02c9e5f2c1d6f06
MD5 934f98d59913257352f6fea06fa13ab2
BLAKE2b-256 140c87ca68f2097bd4442cb76668fc8c4de3aa4a33dd976c488e31df560bdf83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9de962c012e937345fc5fdaa767fa84132cef34b8649e1712e920d19f2ad12f
MD5 b3102462dc3f1c34369ecbb65a2557fe
BLAKE2b-256 ea5e63c230243df3648801cc9728cbbda1750e99441326505de4b5ff53ed2088

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5cf80d7d7f7a5e67a0d9ada54e1ebc3a31da652489385dd17f07d9eed0954144
MD5 37857b211bdf8c2efb2e3aa2f0a788f6
BLAKE2b-256 dae39f8741c6aacdbf16b2aebd0d66253481a782b51bed58d7ff2595e071b1c6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.77-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.77-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0c9d030c02f0af637ece927855efc9f86bd30cdb3c88ac0d1a1570c1700d2f0f
MD5 d6b0e002190e3374c1428b3d23df4b47
BLAKE2b-256 9239f62c0e7899544f27760cac3d5805a613059c8631c4d11b9ab1d8993af02e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 e89fd894ad1087254ad553dc3b9b8c55ed4c9700f4b5e4a6a042c8b6588aee1d
MD5 d36a949c239b7cb0ebe42453b2011480
BLAKE2b-256 69d5111c446750cf9f6e8925e7485f4050a51592cea723e1493509aad97b1934

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c92bf070dc29f2e0e1c46873aaba5426ff2e5d6efcdb7700a79080545d7f977a
MD5 de5bd9a072ba413d442a89da7ced1537
BLAKE2b-256 8f72b803da2ac254bbe11cbaac3cb80bbedb86a37181c8807ab57342e26b4cf7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1142910b52f81bdc79b00d4aaf24adfe627bb8d6d8b47969f3fca220962d8508
MD5 1305f2d600692702a4d54eaf62148bfc
BLAKE2b-256 6d0f2a22e34360c63036f136741543a6f983ec957c857b212d6920f695ad7504

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.77-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.77-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 57e75b6baa52a7609673c00a0644c0894e00790185efa3560efb668cd9978948
MD5 ce118bd67d6f29e105c45088b42068dc
BLAKE2b-256 c990b8627e866f1374b7658ba7da4f58ef93b505ba6b09ba31226b07a041b551

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 ef2b437c1cf8c3cdb3dc72d14a39248a1a3e93ffbb943ea9f288838152e38eb0
MD5 771fda3647b5c2be2a52e85cdb2c4d5b
BLAKE2b-256 5c5ae22f3246384523c7de7eea2bcd5be5923a91817fe833824f5bb5ce0b355c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6a9d69bd130916c948f45d3634177264d36dd3aaac14fded6954c689d45eaa16
MD5 717febd181350f8a80723390bae5a6ba
BLAKE2b-256 61403c41c933439f1858c1ccb1a509a0c76dbe9cd466ffbdca8a3cdd21cdb8bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.77-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ec0f71fed666ac99de19d6b02e0af721efa5a46414332f50670d941041f25cdc
MD5 6a1ec7dbdf2b5dc8abe25a76b51ce7c9
BLAKE2b-256 f86c44330fb51b891ce4c94682b61c6924de6a9dcc960cbabb9f9d32097f7568

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