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

Uploaded CPython 3.13Windows x86-64

kglite-0.5.88-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.88-cp313-cp313-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

kglite-0.5.88-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.88-cp312-cp312-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

kglite-0.5.88-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.88-cp311-cp311-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

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

Uploaded CPython 3.10Windows x86-64

kglite-0.5.88-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.88-cp310-cp310-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.88-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.88-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.5.88-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.88-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7b4f8558ae52598ed8cfb45e8273cc3a154d326a6c8960aa44da389e2b3fdf16
MD5 faeb6ae99b4601fbc231f031e042890b
BLAKE2b-256 0e1fd3dda27e2ec5325a199eb853481b1608aa22594afcfca5302134057c972e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 daef5d43d831abb3d3fc7cfa4ab0b4e41d29ead032eee88a5cba899faf6b73a0
MD5 96bc586785f9bb52383cef3dc638be96
BLAKE2b-256 5b01f189dd0bd621bf3005ea38c023132ee26b3d3c65b5f871d69b63b68a273c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d01e0406b10a40c47a4ea2762718cb2c0332f024e37ce92a2971ff4f3404fbc3
MD5 0f9fe92b66dc8433e97f94c40ab78f85
BLAKE2b-256 a5a83c2529af7dccc02b1a95d47a8dabecee07c8315db74bfbee2da4f37d055a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e63fbf04ace18c670bf53f5eef6bdc7d9383e2be0cc13c6f3c44d02384c56a9f
MD5 b3f15a53bd156bb4929991e83b6bfe8a
BLAKE2b-256 b8de059c7065f28855c5322e2384527d9d1c8b28bbac55fef0a8354e6cc63e53

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.88-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.88-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 500b19ecd47ea6fe4ed022fb19a4e0bed3929cc72f333cf5c9c135b7aa9109cc
MD5 02c509ef7b1c1c1ea24e9bf8cc14e02c
BLAKE2b-256 3e97c5da690de0a3c305c25912e1c8b9a26b7cd263b5b389e0cf7481329e6d23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 2228cf0ee8c6cc980f90dc8a7817e58f5860dab4b2817cab3d5da8fdb309921f
MD5 dd906311294d7249cf9d5c3e7c4380a2
BLAKE2b-256 d0e1e3ba434be9f852818bcc59f7c3bbb1f3ddc6e4dc2630bd35b029ad61f6ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea41345bf6cb2bf0a76aec36c3bd384433effc848702ec35c26060c8614c277a
MD5 e88ce766862591ad2bcab53ef545430b
BLAKE2b-256 cba50dc0c279c22f952df71457709b857b100a456654a1da3c27987284c350c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4b776f016a1cda37e9ee26efda66d08c1646706838b75781142fdd3a5abcfc84
MD5 d5aa93e13d773053754ee1bbfe1dd18a
BLAKE2b-256 9ef30faf60e0aea9ebeadf4cd44b83f8638b833d309b1d4f118114fb3f7c24b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.88-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.88-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fe23357c9f4788b66e3b6ce13626810182d6c6ffd2b597c32dd4e88b5c50ccea
MD5 f6362014c84cb24c86c9cd2d5e4dd25e
BLAKE2b-256 855883629c838b238fa5ba23d876d137876b29c8654590e108cbf30d0cd0e040

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 0c78016090adc5013ee0ccea84cc56cc90dd8e47f07073a97726ebd937164f2f
MD5 c01f18a8b7a8d4ae3ea9ee9cc25b2cf9
BLAKE2b-256 17c100137edd1612ff3485fa5ec3b8a025ea3740d9e70065b2f2b2608c82db89

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0d609ec5f7aaad7560c54d3848ecdee5dbe64d0d20dff003c89af9c639ba8691
MD5 3494f82e7fbdf7d573d12e1a9e83f5c5
BLAKE2b-256 8a5c975af6abe097692757a5124eff92d414cb6aee86a5f1a04af6e3e7bf4711

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8b239bffa17f040c04dc41dddeaa12b0398e0d7842a398c86a8774893aa73eb5
MD5 0e9e35e0e47cb2c084be8bdb2b2dfb81
BLAKE2b-256 fa72b9df0b2ec34c58ecaa44210f503b707602120d265ad27e747aa08259710a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.88-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.88-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3b83ecd0288baebb777a0298877aee04677cb7d5b25c841443ac9c675cfed091
MD5 002784c2dcfa2acae92cc1cb22c238a2
BLAKE2b-256 caa9d313d70431bb53fe2926315a274688a7133f34675ae719adfa2d189a7538

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 04c1f990caa5c138e8436a137a563ce456fd55e88795a5fab2694328632ed0ce
MD5 9f620a31ca3deeb5788af2a98baac4e9
BLAKE2b-256 fce7b4d123dc196db826b36185ec2e157568f1bebff8d0f8bfb78e174858e0f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a8204139ac375322af98414fabf210de64de16cd957646a3e5f5479835a66ac4
MD5 88e785b2dd0f22e985010cbd559cac80
BLAKE2b-256 cb43cab394b6cc0e822f0f7194ca1017b2d6ab679053e75c7013fa12a8c81dfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.88-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cb6603188094817adae61489bf75e9c6ac83ab8c23fc24b74af752d9c7a9d461
MD5 1a3d54b473b4f927f9baa4a5021679c6
BLAKE2b-256 4b4a91b031e9b17d6e12b7cd67e2154e2be85ea27e76ba46501f2603fd5ff5f5

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