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, blueprints, conflict handling
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.73-cp313-cp313-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.13Windows x86-64

kglite-0.5.73-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.73-cp313-cp313-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

kglite-0.5.73-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.73-cp312-cp312-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

kglite-0.5.73-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.73-cp311-cp311-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

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

Uploaded CPython 3.10Windows x86-64

kglite-0.5.73-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.73-cp310-cp310-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.73-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.73-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.5.73-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.73-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2df6ff938af48ac214a05e81576239f9031dbf19761cee99b9efe8b71a3c62ee
MD5 379a9c3999ce6a5fe69d1828d5ab47be
BLAKE2b-256 2ccc8a7e38385570b17babcb940ec0c42eda46f679e562d99e8a67fa55b62261

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 3b21e7febaebeb7d5a7b6f5080ad3ab5b5e0a9031d138bba3b7dd1684fb8e5d8
MD5 02bc0bbc0ce62143e621bf53e4bae049
BLAKE2b-256 26831c713f9ec84868abce2ab443a3a0929bc810c40559d63176d2259794056f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3d218f5089372a97739a0492bbc34e46659eaf08a48aa851c4ebd138422343a0
MD5 0edd381599acec964ecd5197f4e8449e
BLAKE2b-256 14275a39822dd1b3ba2fff6409ab48662a4476365aa5867aac2f49b838c26290

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f7672573ee9ae5693ce34a04f8143c7ee6910b77bc79d96465bafa13ced63ec3
MD5 400cb855b15ab3f08bad9cbe18b33366
BLAKE2b-256 10626e0dac99a1fe7e99b9d525b968b4051f7242424ac7f87c57d7cab5f0c39d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.73-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.73-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 dd3c1f204ba64e7df691e8259ad6acc8b2f28df12ee98c7dd91fbc29c603debd
MD5 c17e94565e93d2f2c824c7c04ec3f7b7
BLAKE2b-256 560c98af4d5e0c29a6f9e6ad9704f118abf2827741c3d6b4fe37247a240dad4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 96e446c87547a6b15cefc5bae52c34bef9f8e1e9b972a0392c64239a04f8809e
MD5 28465dacbdf455e20a638143baa197a6
BLAKE2b-256 28c41d3347c1cfbca0d026619dd0949ece3b14a09d9c32ee6c4800ea85155979

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a0788de7577a49f403d0c2ba4daf4e0152067911a2cc5275ee884416a2c90a8
MD5 4353e6ea2ca699b43eb1260164a84d26
BLAKE2b-256 605b62cd01142b6b7537794ee71469adde79e60ff89c249ab396fa2d868ad5eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 739f0fb9bfd34dfda6c0549dfe8ccc665bd6a658ea4acc85e3b01e74e44aed00
MD5 ef4489ee80d8f6ba0300e1504dbcb194
BLAKE2b-256 88c70c7b16a1494a2023b8cf457cdb2b34d8bf60c582a2072c930bfebf617222

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.73-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.73-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1d303c8a8ed79cc7d62c3327cc790e56ec418bcc6e49c01abd94b32bbca514fd
MD5 65e1d90de53b215b7bd6bdbaf8365e73
BLAKE2b-256 edd86c7619ce1ba1fad073f4a9ba3b0402566b8c1980e792584bdbccbcddd950

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 5d10071227783106ea63a1b9c4073f821d6b79eeb4ef6bf52c18a27c802561a8
MD5 fb9684db93e76561382a3a44c1acf407
BLAKE2b-256 1b64297bd078c6afa15dd47b3e7af523e455a3e8885844cfd021fa6bc870965d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b31da39129182aa07b78fafb8be3e8d10c3f21e162cc0cbcbe8e8c149891e15f
MD5 6a03e1139077aabf028b666b65425ed3
BLAKE2b-256 5bee3ab3965fe5c9806a42f233751050acb47a5f98e42dcc5404b0080c284dd8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 80f06914ff8a9c4e3e0be0a93d9f76e4ba64181e2eb9deb83ac562ee971b2602
MD5 ffee3d3f2fc06fad9dfedf0819e8fc43
BLAKE2b-256 84bc7aabee81c3291355e9a3d6400f1c6a6fb7b208dfa89a962c39fcf3e04d86

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.73-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.73-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 032a02c88dd4f191ed6f1233bce9ac7d6b26b79ab5727b9526e94cfba0ba08de
MD5 050a2b77fc943b6a4ebdb41bdb48256f
BLAKE2b-256 714b6bd23267504aeb35d52b297fc7e74466191f221c8bb56902c5ce4f198658

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 35fe64dacd939220c7310e7f404f98d6704e0cc3472f2d7f7465b9f6ba0e190a
MD5 cc0cf413f88270cb902c9e6a9c82f686
BLAKE2b-256 82d3e41325ba149ae45b3b0eca126716c7ef39d5600bb6048d5513386ff5956e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 176dbe9017b3ed14b14ba6d9d2054996dedd9bd95bb5f311cd2d9d1b32f6d60d
MD5 860cd262b46e086d03ba36894038d8e3
BLAKE2b-256 9a62baf24e6dd0a1db8ceb89820c6cc6995b1957b9efa5a83c24d804bac29149

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.73-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 eeed22b4570ba06217ae26f01f3f50231d30ede9ed44ebc111ed127d0055654a
MD5 e3532871dc5329ee9f23064bb1e651c4
BLAKE2b-256 605d3462e243411e84f4431aefe7a84e1301406c6cf68730dcad77efa9b574f8

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