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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.78-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.78-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.5.78-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.78-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e96f42ee1e2a4ef73f190fd6c6a930d87734fe83df1c2501a2a59fbd2562c3ee
MD5 a44dd5d309dd0727b4d938c227d319cf
BLAKE2b-256 4045fd1ae5d747e219603de694155b01d055ce2575b967e62bfa5f6c7c513580

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 3b036eed5ef657e2d9dccf3c768d0c8782edc4b5b791191d29d194357ef20dff
MD5 1df72e8e8d22a15981c83905692bca4f
BLAKE2b-256 3eac4619e66538474dded58fe0ab6e957e86d7a6824ad2805c65e72a4b9a4615

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e7062cc052489d6505b43a99cc6fd1681a0f0da8b1ed50d20a2df28c001ca53b
MD5 ee0d0ae2c7133457e20fbb2fa025c06b
BLAKE2b-256 a4251f9092a044e7080bc6de81a606de58838cfc65d9c327be76d18359d90fed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bf87659ae571ed597fa32323052d8f39be84bdc19743b5583984716ac865f13c
MD5 e707aaefec9612f1cd9e6f140bc8b52f
BLAKE2b-256 6cf3567cdb14252f7aa1b92b3967f92c23e55e3c576e37e190cb4b4c19dd03aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.78-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.78-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 72d2228ec968089df5669bab862113b7c2c15b6f8261b000410cdf2117f8abe4
MD5 a4309b554f98a5b400a47136a1983738
BLAKE2b-256 78f35bd361c0ce7cc894bf1d9befc239b1fd6d2e87e65feccb5e15d770526ebf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 e443b94b6145396b8b2c29db1725c9b1982d0f4c22ce304f6b461de3e611dd7b
MD5 c8bdd1637c5932d5d9b80667369fd648
BLAKE2b-256 6feaa5721d52b0445d680852d0ed9b00a34fdddce1f122219cd39367d1527715

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90cf9596f7bda30a71a6a5643db2d45f3e9d048ea6773e06b6721ca3a1b4d466
MD5 3a35c2cb8907b1919949d6badb16c1b4
BLAKE2b-256 c971020743399b65db0e1035cfe28d64af0f66c5dd54c09267d51c4e4ac2e5a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 196d6ebbea2001ec9374322c2c0a9d42ca84044c719bff270fcec575244ed0ef
MD5 79546a8147bbffe8a2726c8255cf4dcc
BLAKE2b-256 6e6377203733ff4ef1215d210d270ecfc989daa2b6c164f69af8c22c75c33bd4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.78-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.78-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 64c6969263d87d95aa0f9cf15b51e535235c5a88b234a024b5d60b2a09cd0f26
MD5 11f28e00838a216da04d13a1677605b2
BLAKE2b-256 aa311c11618b9b02fff6c28c8ff2593463b605cffd640f6b1e945a3d57fd5fcc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 e15f78d3da493de7b51b594f08fe1c749c608ffd4972200b212a28774228eff3
MD5 9f77028afbf9a651ecf293ba235ff308
BLAKE2b-256 275e773a5c7db85b1ded95d6afcb415bf26558939bf56ef48ec93cf36aecb06e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c73254a02041a57d715fdd7d48becfea4f746176e5165eabe6410d40e51f5a95
MD5 1a011514dcbeec78c1d65dea4338a42b
BLAKE2b-256 69d8713a71bf6585333e49b774f86cde8ca480b297ec30e9c66abcd7449d104f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ac566da7d9f5dec0cbdb4767939a5a0643f02e8671870b00ea87cc99f0d61aa9
MD5 54bad2754992d3f47f72a2d266792bf2
BLAKE2b-256 a1e3a660bdf02b92fdf8995ee11da1a19ac855f5928ae09774837fe323b63918

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.78-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.78-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 97bf4804740923fe6eaea0bf5d440ccc8d681cceaeb80c6cb9c65029fe8b4325
MD5 d9fe58b79beb39c43bb4ef8a1936a758
BLAKE2b-256 60358cb2efcab11fe966698f1a43298dbb7f7a3e45a7fbcd7194aced0b199905

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 bdcd9bc0f17f59b087ab8f2f8d8e15209fd724f35ee8842efaf8755533a565d2
MD5 8467343a866284a0f4a93e57d9dfdb7f
BLAKE2b-256 8503621a5182d31f900640267cbc3d39748d372ecd738b793752c9aec157770b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 771ff4c1702e35fe6c4c0a107fe43fc7ab50ed78e5c87e7cd5bc1ba8efb2ff5b
MD5 bb34254268aa441450d8a6a776def628
BLAKE2b-256 54e226b5406ebc3df6ed0e38e95f7fd8b1e9913c52fe49664c8cf739cf9d768b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.78-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dcf9d3cfa5988392ffbee8a6913b1e6f78ec57b3c734a365628902fdb4e93658
MD5 786077daff79d4e1d98283ba40bb34bb
BLAKE2b-256 fe2bc5af78c353863ea698fa712f319a1a18c3f12eff6fe3b7059cf0135005c8

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