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

Uploaded CPython 3.13Windows x86-64

kglite-0.5.83-cp313-cp313-manylinux_2_35_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

kglite-0.5.83-cp313-cp313-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

kglite-0.5.83-cp312-cp312-manylinux_2_35_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

kglite-0.5.83-cp312-cp312-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

kglite-0.5.83-cp311-cp311-manylinux_2_35_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

kglite-0.5.83-cp311-cp311-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

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

Uploaded CPython 3.10Windows x86-64

kglite-0.5.83-cp310-cp310-manylinux_2_35_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

kglite-0.5.83-cp310-cp310-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.83-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.83-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.5.83-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.83-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 01ee179e3578be2d0df4d115b62839d50956038929cf686fe2f142df45df850e
MD5 75220fb13a3dfd4078988e6049ff9628
BLAKE2b-256 4c81b0d244585cb224dd279e2a3d91862eeb43f96b91553e487bd7e6bb017c06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 7109ac5eed1b95880ef6267adb55adfa5c41d01bc0df099e5d3fdb09e249823a
MD5 514e02b92b0d1358dedd380895b311fa
BLAKE2b-256 e6c0c8a57f139ce63e2c9c851c51e3f445f60d6f9c1c70760bae853ac61fb230

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec1f94b7eb52bcc1e42040388c5dabb79ea4091d48e0ace3637c193f56274601
MD5 643a52ef296fabce0628c46fbcb036fe
BLAKE2b-256 9150b05b2a6d6878183d98c319b9dfc9dc4a3dfa134318612901a13df2dfc527

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fb76dd1f20b05da9a1c375a6a21b7b66f4614c8db6065fa12403d54845047e9b
MD5 59204d3de4b4de84a765bcf73b78fbe4
BLAKE2b-256 1c09ed9920c7be48ae87c9887ff5fce4c85426bf16af8c10f9ed4200f33f0154

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.83-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.83-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2c41fcc03d57d15757d0e5383bad9f5abceb3f669bd969a4baf330e18ad1dc49
MD5 c4da22f97f4a2721a06f37edb9d01dcd
BLAKE2b-256 03ed3fd7470d3d650190dda3e8b16327f9340876f76e3f171ab3ab27bee90b40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 6769a0cbc87779b4be1a6e5df53d19a6cfdfebb75d25e00b1a3d4bef47d99157
MD5 28021d51813ed2f408cfdba2f3296295
BLAKE2b-256 a32799dd82e1b516f2c7835b7b4fdcb74dcce74ed5a22ce197dc3f1b715b7af0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a7c36936d5041ec33e05504fc1830c44375aceef4e06bff8408e74032300843b
MD5 e69a23ae6373b44c3e63a35c11c8deeb
BLAKE2b-256 b276ea6821f82e302b8c85a5fa32f6fe9b0b72551f21e3046cadb43cc61f29b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d032299134f3591041fd206a1f2bfe6bdcda1779ba5bba07a578034b9c232503
MD5 52a91deee0c631d5d9ec09e9f2975119
BLAKE2b-256 c0b376bd934bed27b8a9ab5fcfa5df6cefacc43ad48f30c08b9eabbc0614e697

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.83-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.83-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4e85d2ce5308349060a0cb94b0d548ede95e993ffff59fa2895da46510e43fe6
MD5 2aeb66be2084388552c602b7efd7a032
BLAKE2b-256 0bbcd0031bc47bfee57e139819045040406d3943f95eca55722b6ddf9508c96e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 0abaf8835fba23b1b2c69816fb30c473c873702bbb0329c262c7bd8baa7ab786
MD5 2719bbf9f0bb7ccf76a846f4565df8a1
BLAKE2b-256 2959c99c9b3f8c03e4a5f6c29b7e208f9ac7b8ef12442a87246184a946429e78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ddda73de1a08150875c101013e9e824aa5d58ec06eb714df58de844866548577
MD5 a189159839669f53ae07d21a301d53d0
BLAKE2b-256 ce8fa2a548a5449582f5b82d3e02e13c80317ec0a6098224a7d95dc91a0346cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7776ce147d5bb6c8744bf2e4a92a3e49d840328653909a8556b638c2c50eddb1
MD5 471fd04ebc1c7272a3d73fb21ce743cf
BLAKE2b-256 5116a207fad538c2f6b839c30e6da0669f59f9552b6cd755480c62c00c190ec1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.83-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.83-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2bbeb37b730a2f884fa199a89c6f7f677acd2a59e842aeda7538dbdc477d557d
MD5 03f4db760320056097f4627bc42a65fa
BLAKE2b-256 81eb18fcb3401e174fded36176072949ac0381ee5488d20f096a73dca82131d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 4b66c954f7446fc999cadb8e71aa3fd8535aa6f153939a434b79b3831d0ba06e
MD5 8fef2e7a0968d252a7646221ff7ac47d
BLAKE2b-256 e32214b3b1616595e789bfbf1ce666b7c2496f639c609bac878beef6787caff1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 67eee62194fb0673e466237bb7242da4259d8aa1659b3ddb51653e663910ab55
MD5 443e165292dec962305b31a5aa9205a0
BLAKE2b-256 0f3861dceb7988141d7ddeb733866574380ccbda9db2f199746e4de49d1d1954

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.83-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1600e9cf38f2e6be67311c1960356b0337b810b1e36f8a5b540efc8f29429156
MD5 1597e15b6fd5fb5e9e0a9bc094485202
BLAKE2b-256 d8625d2d10e4532f51efd060dac166dfff4ff2c5f7eec31e6236078c9dbb973c

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