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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

kglite-0.5.74-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.74-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kglite-0.5.74-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.74-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9727052ad29337d71733d5802fc89edd46bfe8ccc1291b9cb9a73a21e4d5c1b0
MD5 4fb7268ac38ee80b335e3d4accac2b28
BLAKE2b-256 e04bc9f8df961a09287c28ea8460f78756c26ecfb47c742dce14be8a4fd34e04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 45cfaa9e5e6963e5060665a4f9756ad73828aafa215615eff9a0f24ec4e3acb5
MD5 2ea477b7786bb92ad650539537b59e0b
BLAKE2b-256 b005eefa92ddacdc045020bd312c81b3ecb7b60675eeca11a8be9456b9201071

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57f75523fdb8349bb490d751fa7101af4f455b0e914f6dc263f29172ae455553
MD5 3af31aba30425d84263b24e25eeee2a6
BLAKE2b-256 0cf4e54af5b79aa270df68f7542a14107839f41560afef5305c9b15f5f661cc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 765a09be63eed25e054b1a74ae524d466f973c500ad0fb19392481cb3a5a8487
MD5 cb22a1342604e109fdd142d52f4435e7
BLAKE2b-256 24a0ad3509988a030acc65ee50c50544186661edb58323caf237771fea4d2aa1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.74-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.74-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 57b452ac1969e157e6198867b49e3e17445d17adf559f345e9f92542bf9e52a4
MD5 d4a1a2dd6a72b3eab0aa2f5da89bab51
BLAKE2b-256 c703942beef87589b75b17f6b038f892ea71091958e72237eae439c2bc4e4cd1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 db40c5fa3943e6d0288240a4cf10ab1014814221db6652526f996d11282acc0c
MD5 98a07804ea12d3cf22271bada25671ed
BLAKE2b-256 5298592a6b6548837b92ef030f0e26f03ad655f66dc2c58d6c8fb35455e9f2cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fce0d37e363f8fac9470b4b38b090dc60c99d6688d3d9aaf130b56e274b75ab3
MD5 c33885435ecfee763245fff1db12fb14
BLAKE2b-256 a087244144a5454d1e53724939cd32ce0663be174c65aa5b143686cb8f38736f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bf2c7e7c43534fd76b56b8066a17ee550e5cc9ec8cc695b446ee89cbb7ec192a
MD5 7b2e536de7941dfbc86b9acc226b3947
BLAKE2b-256 c9a8794f6bfcb57aa3bd5d391e89661f68581d9409d6b83f398a69164e539125

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.74-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.74-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 470313dd5027eae771a91617eea70113c516cad3895b41f94b8bb366bf4f6497
MD5 2b6d28b813e730874b480ddf7b4501ae
BLAKE2b-256 6aa7dbe4b7ec0f15a49f0821d4358d5eee2ed36bb9d5318bff2d5644e5740b64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 7dc86941b6bc49bccbbf0c78cb420cf0ec9ed7b49da2a3448c443a654d95be63
MD5 69914ff50dadba8118b1defda9eb6853
BLAKE2b-256 5981de12433cef1235c472a8c4deff09facb127f1a73d41e3e98a56d3cc7c2a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23403824adaa86d58e76258e5bb92f27204b946fbb5847c8524cf85f470f15b3
MD5 5c04fbd865336a02fcd5f1bdd987826c
BLAKE2b-256 e83e4715ae3084f537521d4f75b43c78bbc1b0b8de2e38912618124146f6dbab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 50f920ce4e8f018aad2d44985dccc5869c1dee2a320ec758c734382c7d2a251f
MD5 abb4d1ee2b25d57b033d24f88272c0c9
BLAKE2b-256 f2db5787d54e91f4aa14aea8e17a9e3460341d95803cdb64293863b813d24418

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kglite-0.5.74-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.74-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 28e3e68acee9d0764f5d010a487c1a1dfc906fe264c9148aa916bf43a4635633
MD5 b8f81724275434de319b7585ab2a6a9b
BLAKE2b-256 c87a39e61aca7cbce3e5a196e24bdd9a42a295d62597766f46030b85f0f2554f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 e214c5f267ac1832218256ff2b1a2f0765cfaf036a039d35abe2e343867d98f9
MD5 a6a1e75e813294a21a4d009018b3fa85
BLAKE2b-256 b55f50d12292a8c4b0a300ad123359d0d549bdb2eee6977a6fe1613c96e11326

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e525a113d912260f965e59401d3e344aedfa9ff9f986f7a0f236945cf9e3e292
MD5 a9e13a95aa21ca7c17d7aca5f9a99383
BLAKE2b-256 853f65ee252442ac09d29724d08276fce7c8e54786241606d30053e351f1a8da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kglite-0.5.74-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 909e1371ebf7892dd6d2ce1df130353d4c2021c857b1232b0b1722d3c3a5b6c7
MD5 6d0d546c993a1ce6c5d6afd5933a789c
BLAKE2b-256 6bc95d6367077f6a56561cea2e54b071c1ce180f66b0a37442503f1a61d54191

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