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

Uploaded CPython 3.13Windows x86-64

kglite-0.5.80-cp313-cp313-manylinux_2_35_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

kglite-0.5.80-cp313-cp313-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kglite-0.5.80-cp313-cp313-macosx_10_12_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

kglite-0.5.80-cp312-cp312-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.12Windows x86-64

kglite-0.5.80-cp312-cp312-manylinux_2_35_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

kglite-0.5.80-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kglite-0.5.80-cp312-cp312-macosx_10_12_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kglite-0.5.80-cp311-cp311-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.11Windows x86-64

kglite-0.5.80-cp311-cp311-manylinux_2_35_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

kglite-0.5.80-cp311-cp311-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kglite-0.5.80-cp311-cp311-macosx_10_12_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kglite-0.5.80-cp310-cp310-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.10Windows x86-64

kglite-0.5.80-cp310-cp310-manylinux_2_35_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

kglite-0.5.80-cp310-cp310-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.80-cp310-cp310-macosx_10_12_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file kglite-0.5.80-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.5.80-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.8 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.80-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2edc5235eb46f7bfd98fc4d67befec2a95bff0cb1836046bf151b2df49455c8e
MD5 f1b35dcdde47cd864cbab75a5f098ed7
BLAKE2b-256 ddf157e0a431a9682091d3f9b932225e38ae985f3d3b8fd6ecece666f745453a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 728c65904a38eb3a6274b6093ed080fa5c7315cf2c8816f47f6402365d00431c
MD5 7980bafb60fa57507ebbfd1a2d38b25f
BLAKE2b-256 afc75213953d923e2aca14a7d01e3e4daf7f6b191d87e722b15065abd779691c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9cded09639135ac63e1ed83cd3cd7f0684e7a944d8e47a811329b25a3b40ba2c
MD5 e5ff800a04bca9e9ed4b67753ec2628d
BLAKE2b-256 73f48e23864a01d53143ac4eba457e5e09098c204b90f32315509918ed03f983

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 75c1a78c58b28558ec909f0f52244847dce4fcc4a6e0b443440dccce7efc5ac4
MD5 2364651ce7a56d30960e8cd546382c83
BLAKE2b-256 df2b9868f052e90ac04e955afa6030431eb4c279d6b168244452fc004a9e8c4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.80-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.8 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.80-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0507ff25ceb56e439f6763f1997ac3f0866d2e270af4c7381d4d6b93358d10af
MD5 da9d5da76c1a480fc34496ad813190b2
BLAKE2b-256 1004617a197af26e85f1c46664925475008c37cc026a3030ae7ee3821ffda31c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 120109a037a082e1073e323975934081006518e6d10a98ee81b06f1e61ad94b1
MD5 c3666a9f906435a50a637fe46f2d2a83
BLAKE2b-256 0dbc79a41344d64fe2ebd9fb13b90efd035bc607b5a7a3871e00455d7879f6aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b83654465b0872890b7c855f304f97ca5aa14204c585e6422aa82f87dd3e61c5
MD5 e14209728aacc89aa0bc646078eb1e4b
BLAKE2b-256 4b41f8ffefce75e5b1e14162f05b4c3fb41106f74de6ae6bc4ba171a88c1cc4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 68cc567fd08947ee5b585c2c59327851837daf56eda61e2bf4c7c70579a9317c
MD5 eb80be8648d08e3cc7c906a9afbd96a9
BLAKE2b-256 1d4c32e5ab46ae49c8396739302692f389dd4cf4a9e15fcf67141e938772e6ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.80-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.8 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.80-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f818fabd5ba019364c89c821e3c2ae9f10f0670f062d631ff0da8c1206d56316
MD5 906b3171c8c2d570914cf0970e5aaa12
BLAKE2b-256 eac37ae9374b91319c1787760e0d91bbd7107ce747a36cc252b7e394e913bdd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 2bcc452e494396faaea922b2bf56f6e68ac10147e96c07e149cd94e4fe0ad17f
MD5 80d77ae3dddaa5930b75212690be859f
BLAKE2b-256 5308ee5e7c03c6f96aabd9da90e4475eab1f78be73ecff19063ef83e06798f32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dbc4680a72e0c58ef8548f857fff13bbd58083945061e4c0bf0e815614ab85c4
MD5 81f3fd93d96572f81e121b1765e15dce
BLAKE2b-256 12f945e894b965c1fdec6124de3e80a0625580bc1666a40402d5b5763c83e9a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 61003b4175ef52dfa09beed787539de2b4367efcc652e38a123283dd29f41714
MD5 ca32fd4fc83c886e1b1ef5d586b66a84
BLAKE2b-256 ac82df093fed45b69fcd68f542aff86062cf6037e71173070fd84806641a0254

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.80-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.8 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.80-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 88036ebc4a7b25365db3f6bbc9e3921de22472edbda91da9abdb4f16bb594871
MD5 c014b962d560800eccfaed239e119b4e
BLAKE2b-256 66dda3f4dbc1697f77cdb5bb686c9a388a747532de8952014f41aedf1c618f1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 9c9569a15eea6e9c93f4ccafa312836fb986114e9f219088f4ad53bece68e441
MD5 110bc7f3ec0730701f15aeaf8abaa056
BLAKE2b-256 e967135fa7c39e9928f5127134a5b91526711be47c249d7293088b868a390bb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ae242c2c18242ccf84a3ea1e2afb441ab0d1112df3149b8a374dfc14031f801
MD5 a23fa9b75012159f42de17e82e74f593
BLAKE2b-256 0d8abc919c99c5201d97764e59c6ffccf776fc9c80183c9fadacaceca9471fe6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.80-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 06fa7e675108d6c9c602f7e64e9ffd749c6a9ef72e77da1b291a43b8e2221fd2
MD5 d4c95c5100441478ef81bd21cd11928e
BLAKE2b-256 18d58b7dbaa592e2eeb6a6857a4f615d511fd7bafcbb8d48fa53d851cc92c938

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