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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

kglite-0.5.85-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.85-cp312-cp312-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.85-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.85-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.5.85-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.85-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2cb2df37a108c315eaac8de8f11d95a69bb2771b1cbee0a5713aa310790d9fe5
MD5 5301a867b9171b0e387fbb1670ad193b
BLAKE2b-256 ed3d29010d43c4b3db1097ede59fcfba7bbb7874bb7d72b690b6a4a0e284b011

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 368ce21bb6e3ab37524e2fac53b1c463f37338797cdd19f7fcdea7b16b49a563
MD5 8e3c943002f8f6825c419c0cd6a959c6
BLAKE2b-256 28cb02aa0742ea3ed3ddda999eefb33db121eeb97977175e0d9ed0405674441d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac77d7421cecdca0249237af2fb337dadcdb13013a0de23f97afc779ef7ec353
MD5 4c433ad8f29ee1b8ec27759ecbb8f9f0
BLAKE2b-256 9d0b8cb52cc947cfbdea47a36a7ea3024a862cad406147a4d293ceab69411030

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f7bd699456caa12f420cb977a0b28e7a7ff2a858888c910408d12e1a42c4644d
MD5 abb739d4279dbfa0c2b87daffdcdce64
BLAKE2b-256 757daa79615c0d743b53fca9b557abe2a9068a370fd0b8c8b3e7debce80c9baf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.85-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.85-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2c96ac75f860d386cb8f2fbd5bd78d7505d5337170c811b2c7969dd61cd4ca42
MD5 27de910f4eed4c285d5b1f9f7652ccd2
BLAKE2b-256 4558a1c2d9408e18813cdbe664ea831ff48f3873db6307a0833f952d06ceb25f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 7a052a4db6d3427cc7237dbaf5a83846488781906c6913fbb81e095783579d23
MD5 04b1fc00a8004c97104c3fc8c82af2bf
BLAKE2b-256 bcba274037d5fe051ac8ff4c9685848d44956e96566dcaddb808e43b23170436

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8a43b7a1b12b2f4c010a94bb2e66092191ebdc0b96c549a9bf40582b0a35aff6
MD5 27687ac5e90b836c17b7161519b92aae
BLAKE2b-256 ab346020324ad91d3bdbbb82f55bcab87aecc554a2758074545d9749cb9404cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 92615d53cf70c7633641598453ef532a75ae8108c019823e867fda8943c2d198
MD5 0ad46747517c58f7dcee0f3e03cba0f4
BLAKE2b-256 37d65506ea56befa837b51baaf33d07e09762a3a2c9ee4aa6d1568129b5a33b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.85-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.85-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 781337f241e541374d45c0b5e2ca2e35646315175ebaaffbdbf0c3216a839817
MD5 afe558bcab48b86b31eec125624fd684
BLAKE2b-256 1b7021f403cae2cd34d71627a93beb54c890d8882c99cb4f886bbbe22f819ec7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 73441e5857c4c7eb3e7bc972b1b863823c0cf6450e38f05c79346000a95ed38b
MD5 33f2efdd7993bba01825411e8153bef1
BLAKE2b-256 dd1a8b05e5d881e4a6d1e17bc37069f12d96e6793a20ffeffd37397c2c946f66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a0596bc2231726627f10756a0767274747813824dd5ff692a07e5a4491bb4a86
MD5 8afc4f1b729b4f5706d246aa1631d135
BLAKE2b-256 8272107c27482d75b4fb5ec52012f27cf2f2266de542155c64c3b6042e30fc65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fd7b360f17926522f49a44a5104e6ff99637bd0fc49f194e27977feb4b5de3c0
MD5 92e6f2d33165d21ebd8baaf0d24ea405
BLAKE2b-256 b69ac05007d18b862cf072e0b008b65fa07263d798ee71d0e364fee660aed68f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.85-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.85-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b352ae08493fb02c42088b8032791b2867f73942010f24989d5401e418c163fa
MD5 bf7e2313d3ab1ee9be2daa697570ffd2
BLAKE2b-256 a360b91ef2db9c87a6de09495d2c6ea48f295f7176c7ef8e4709dcdd9b9f84db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 52afdff967dbc3f5e970cb4fdf696cf4db709e9e7048f00e42731b395dfa8835
MD5 63a7c8683e3b8e1f9723688181bfbf10
BLAKE2b-256 a4596c9e641dee076e7f85c8bfbf72ab6354159382c25fd787a4dad8e970ab31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 714fc8106ad226c039c6eef01967553ceecae2e7d9a6743763dbfe09283772dd
MD5 b7f47223ab121f6eb814995d97164b4d
BLAKE2b-256 8fdcd721c942083c47273d6f85c9a45067b100c37af20cbb1d17b75812bd5e99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.85-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1e39723edf6d2202bfb96a271202bc1ab3ba70a007aced2c98fb2e042bf72c03
MD5 21c830996206504617ddd1a2520dc464
BLAKE2b-256 0d7775d302f8434fa49db3b9214e99733895ac61d60e36b309ed4fa876e6f35c

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