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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.87-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.87-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.5.87-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.87-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f9ed20d1d7d2be31ab380eedc65aa6fbc895f413b745dbefdfcc3448f44652d0
MD5 1076224bca12397c94b460442b2ee9ae
BLAKE2b-256 6e6c8968e2dc4f341e7589d7fcc572daa1494dd19f8f240bc9fda20afc4e7043

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 c18604c0d593cf7ffce37ea6585fbb1a7e97f937aab2a8ecda9b70c68f2a738f
MD5 9b94da9fea9fbf97f552311a07c2c581
BLAKE2b-256 ff1d76f4af8274c0bbdca38dfccff49b8f8e5084aded8360647e16d7ab7f3019

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e76ddbae4210ea26e1e00c0040ce09a860772c6734ca39a79852c37db84dc84a
MD5 4b24cf7d2ac626633f65d30fe5c11083
BLAKE2b-256 62f0166009e55a7256ff790a84ee0da8118716aafdc20dad8f5f353201b32ab7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 647fbb3e2323a1392f78349b6f0640d3335fb2ef8cea0e87920e7e26a6b0322e
MD5 a2512ee47bc6b891a92d011de4ebc70e
BLAKE2b-256 9ef68653adafa88d58122703b04302126e2b68d51bcf3e6a116c8e57f2cfb2aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.87-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.87-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4a62615a8477fbc1b684f7b92b4ed00d54eadb9c292bee4592fcd63bef92438a
MD5 17cc0ab756bb9a15628538faf49a38d6
BLAKE2b-256 e0f3a1f41e9f0c48c38863767197988475bad200fcf8093606bb866b858dfca0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 b942b42b5f00900cb10ae8acf50dd94ab0793e6fe0121c2d195d6a2d6953d539
MD5 8b2098a8c854400cfed95c83b37f97a5
BLAKE2b-256 6720e5fe937ca3b1b4395a2c39161037af675d6ca236ce09f3b74fbedd6b8420

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6aa7142cbea8ea196c33fd43d9d88cef96661eaa6dd9c0338beca91fc697bcc5
MD5 a894bb2efde6b306b035af70ad046ec7
BLAKE2b-256 36c8e0e64091919fb471840b1922ff897ba00949a62369a5c753b3d41e8f6937

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e7e31a0095604f377531b13106f988c4f0c1e27f10ad130ae6b95401f69422db
MD5 ed8b1e2f106baeeac639e25954509447
BLAKE2b-256 55ed778ee1f93e6988ee8c0f944b0f2a95e9c5a777cc1303d2aeedbb82b757cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.87-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.87-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4c7ae7cbf57b34c8b16136a6d12a6810681e0f6a7b039926c27773279f8ba539
MD5 0766f222a155e8c5bf582f9ea404c22c
BLAKE2b-256 b471a870851ad485b24d1e57fad4a6e99718e4d517cee36725f9a919c102dd32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 dc545d0797df9d802ea1efeedc0b040b38643c944bfcfb3738a499e2517359c0
MD5 c617b2902115df15908b67d1519b453d
BLAKE2b-256 6bdcf68383bdf867aeb1c37d731ed604a7fa2a2cd23c68d444f6c585ce258a45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cfbe00ff7ab2e0635a64d5126b2892b9156593b0421f4591e18c5c5ab40fdc56
MD5 ee3c149fde61cfc956cbf284a799dfc9
BLAKE2b-256 f23005850fa4896b460cb77373d83a1ab7cde612326d4cb22f1906c35b982f95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6acafd429de5152a4b1a2db3a69f7a8473263ba9fed85d30e19c7f6e836e7dc0
MD5 39786c496ccf2a4d7cdf59cc678ea522
BLAKE2b-256 994d5c1a91c393e6c46cfa6ce1d4338e4d148eeeed9311b532506e60a3532fa4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.87-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.87-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 33acd4d521fd31c8e00d013856ea4d8c8cb186fcf97de5917da426beed30b93e
MD5 3e2c1ffa9c4ceaeccd66c857f335e8a7
BLAKE2b-256 1e76690a62795819e184a4a600f914d666def992c043ee5b3c00f46ec410f98b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 d3319b3132b934119dfa85cd3ffea0762fe0009102dc492c724d6e7013035702
MD5 28f7193c86484c85d2b72084a215dea5
BLAKE2b-256 a3dc4d9e28dfce13b97622b5ae20c96ea5ea5f87eeb43a83c152e9bd3180fb0d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2862f9dedc00a597f4b14bb6c07e5f84968c626da5f116da687d2b12f519fc3d
MD5 f24351f2c548bc4c0d0e9cbff6d96f24
BLAKE2b-256 be993e177a54572b69757219d3861129c7f515b93ab1071d6d62d4386fca516b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.87-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 44143c300edcdadfd337b6eefd14eba2d869fc9ddeaa1b93c3b739842bd4740a
MD5 e55edbf5c372e753430ec5717d6e6a08
BLAKE2b-256 ab57c636235a0139ee74ab4e26f639825df94db674fc85cbefc14c12fd3a15da

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