Copy
pip install -qU langchain-kinetica
.env 文件中设置:
KINETICA_URL:数据库连接 URL(例如http://localhost:9191)KINETICA_USER:数据库用户名KINETICA_PASSWD:安全密码。
Copy
from gpudb import GPUdb
kdbc = GPUdb.get_connection()
Copy
2026-02-02 20:54:50.972 INFO [GPUdb] Connected to Kinetica! (host=http://localhost:19191 api=7.2.3.3 server=7.2.3.5)
QUERY 仅为示例,不可直接运行;需替换为能返回数据的有效 QUERY,且 SCHEMA.TABLE 组合必须在 Kinetica 中存在。
Copy
from langchain_kinetica import KineticaLoader
QUERY = """select
oid,
object_name as text,
creation_time
from ki_catalog.ki_objects
where schema_name = 'information_schema'
limit 10"""
kinetica_loader = KineticaLoader(
kdbc=kdbc,
query=QUERY,
metadata_columns=["creation_time"],
)
kinetica_documents = kinetica_loader.load()
display(kinetica_documents)
Copy
[Document(metadata={'creation_time': 1769036399161}, page_content='oid: -263809000193198488\ntext: KEY_COLUMN_USAGE\ncreation_time: 1769036399161'),
Document(metadata={'creation_time': 1769036399260}, page_content='oid: -6302080570668733378\ntext: KI_PERIODIC_OBJECTS\ncreation_time: 1769036399260'),
Document(metadata={'creation_time': 1769036399402}, page_content='oid: 8620184385195410035\ntext: OBJECT_PRIVILEGES\ncreation_time: 1769036399402'),
Document(metadata={'creation_time': 1769036399219}, page_content='oid: -582966432601743881\ntext: KI_HA_CONSUMERS\ncreation_time: 1769036399219'),
Document(metadata={'creation_time': 1769036398744}, page_content='oid: -745341673129057292\ntext: COLUMNS\ncreation_time: 1769036398744'),
Document(metadata={'creation_time': 1769036399143}, page_content='oid: 7168154014071633303\ntext: INFORMATION_SCHEMA_CATALOG_NAME\ncreation_time: 1769036399143'),
Document(metadata={'creation_time': 1769036399352}, page_content='oid: 2994153253665268119\ntext: KI_QUERY_SPAN_METRICS_BY_SQL_STEP\ncreation_time: 1769036399352'),
Document(metadata={'creation_time': 1769036399098}, page_content='oid: 2689064758811356754\ntext: INDEXES\ncreation_time: 1769036399098'),
Document(metadata={'creation_time': 1769036398543}, page_content='oid: -7679099635043663749\ntext: APPLICABLE_ROLES\ncreation_time: 1769036398543'),
Document(metadata={'creation_time': 1769036399434}, page_content='oid: 909900969452802786\ntext: ROLE_TABLE_GRANTS\ncreation_time: 1769036399434')]
将这些文档连接 到 Claude、VSCode 等,通过 MCP 获取实时答案。

