| name | kinetica-code |
| description | Activate when the user is WRITING APPLICATION CODE that programmatically interacts with a Kinetica GPU database — Python or Node apps, microservices, ETL scripts, or streaming data pipelines that import the gpudb SDK, call the Kinetica REST API from app code, or wire up Kinetica connectors (Spark, Kafka, JDBC, Airflow, Flink). Trigger on requests like "write a Python script that ingests this CSV into Kinetica", "build a FastAPI endpoint backed by Kinetica", "set up a Kafka to Kinetica pipeline", "use the gpudb client to upsert records", or any request for source code the user will save, version, and run as part of an application. Do NOT use for ad-hoc SQL, one-off table inspection, schema exploration, admin commands, or map tile rendering — those go to kinetica-execute. |
| license | Apache-2.0 |
| metadata | {"author":"kinetica","version":"1.0.55"} |
Kinetica Application Development
Kinetica is a GPU-accelerated database. This skill teaches you to build applications
that connect to Kinetica using the Python SDK, REST API, and common data pipeline patterns.
Kinetica REST API Access (curl)
When you need to call Kinetica's REST API directly via curl (e.g., the user requests raw
REST calls, or neither Node.js nor Python SDK is available), you MUST read
references/curl-api-reference.md first — it covers
authentication (.env loading), required flags, common endpoints, response parsing with jq,
and critical gotchas (always POST, never use -u, data_str double-encoding).
Critical: Kinetica SQL has important deviations from standard PostgreSQL.
Read references/kinetica-core-rules.md before writing any query.
SQL Knowledge
This skill includes core Kinetica SQL knowledge so you can embed queries in application code.
Python SDK
Installation
pip install gpudb
Connection
import gpudb
db = gpudb.GPUdb(
host="https://your-instance.kinetica.com/",
username="your_user",
password="your_password"
)
options = gpudb.GPUdb.Options()
options.username = "your_user"
options.password = "your_password"
options.skip_ssl_cert_verification = False
db = gpudb.GPUdb(
host="https://your-instance.kinetica.com/",
options=options
)
Executing SQL
response = db.execute_sql("SELECT * FROM my_table LIMIT 10")
records = response.records
response = db.execute_sql(
"SELECT * FROM my_table WHERE id = ?",
data=[42]
)
db.execute_sql("""
CREATE TABLE my_schema.events (
id INT NOT NULL,
event_time TIMESTAMP,
payload VARCHAR(1024)
)
""")
Bulk Ingest
table_name = "my_schema.sensor_data"
db.execute_sql(f"""
INSERT INTO {table_name} (sensor_id, reading, ts)
VALUES (?, ?, ?)
""", data=[101, 23.5, "2024-01-15 10:30:00"])
records = [
[101, 23.5, "2024-01-15 10:30:00"],
[102, 18.2, "2024-01-15 10:30:01"],
[103, 45.1, "2024-01-15 10:30:02"]
]
db.insert_records_from_payload(
table_name=table_name,
field_names=["sensor_id", "reading", "ts"],
payload=records
)
REST API
For environments where the Python SDK isn't available, use the REST API directly:
import requests
base_url = "https://your-instance.kinetica.com"
auth = ("your_user", "your_password")
response = requests.post(
f"{base_url}/execute/sql",
json={
"statement": "SELECT * FROM my_table LIMIT 10",
"encoding": "json"
},
auth=auth
)
result = response.json()
Application Patterns
Query Builder Pattern
def build_query(table, filters=None, columns="*", limit=100):
"""Build a parameterized Kinetica query."""
query = f"SELECT {columns} FROM {table}"
params = []
if filters:
conditions = []
for col, val in filters.items():
conditions.append(f"{col} = ?")
params.append(val)
query += " WHERE " + " AND ".join(conditions)
query += f" LIMIT {limit}"
return query, params
Connection Pool Pattern
from contextlib import contextmanager
class KineticaPool:
"""Simple connection wrapper with retry."""
def __init__(self, host, username, password):
self.host = host
self.username = username
self.password = password
self._conn = None
@property
def conn(self):
if self._conn is None:
self._conn = gpudb.GPUdb(
host=self.host,
username=self.username,
password=self.password
)
return self._conn
def query(self, sql, params=None):
"""Execute query with automatic reconnect on failure."""
try:
return self.conn.execute_sql(sql, data=params)
except gpudb.GPUdbException:
self._conn = None
return self.conn.execute_sql(sql, data=params)
DataFrame Integration
import pandas as pd
def query_to_dataframe(db, sql, params=None):
"""Execute a Kinetica query and return a pandas DataFrame."""
response = db.execute_sql(sql, data=params)
if response.total_number_of_records == 0:
return pd.DataFrame()
return pd.DataFrame(response.records)
df = query_to_dataframe(db, """
SELECT region, SUM(revenue) as total_revenue
FROM sales
GROUP BY region
ORDER BY total_revenue DESC
""")
Development Guidelines
- Always use parameterized queries — never string-interpolate user input into SQL
- Use
LIMIT on exploration queries to avoid pulling entire tables
- Handle
gpudb.GPUdbException for connection and query errors — for common error symptoms and their one-step remediations (missing env vars, gpudb install failures on Python 3.14+, etc.), see references/error-handling.md
- Close connections when done in long-running applications
- For bulk ingest, prefer
insert_records_from_payload over row-by-row INSERT
- Remember Kinetica SQL rules from the core rules reference — especially DATEDIFF/DATEADD instead of timestamp arithmetic