cassandra
Apache Cassandra is a distributed NoSQL database designed for high availability and linear scalability. Learn CQL (Cassandra Query Language), data modeling with partition keys, replication strategies, and integration with Node.js using the DataStax driver.
What this skill does
# Cassandra
Apache Cassandra is a peer-to-peer distributed database that provides high availability with no single point of failure. Data is distributed across nodes using consistent hashing.
## Installation
```bash
# Docker (recommended)
docker run -d --name cassandra -p 9042:9042 cassandra:4
# Wait for startup then connect with cqlsh
docker exec -it cassandra cqlsh
# Node.js driver
npm install cassandra-driver
# Python driver
pip install cassandra-driver
```
## CQL Basics
```sql
-- keyspace.cql: Create keyspace with replication strategy
CREATE KEYSPACE IF NOT EXISTS myapp
WITH replication = {
'class': 'NetworkTopologyStrategy',
'datacenter1': 3
}
AND durable_writes = true;
USE myapp;
```
## Data Modeling
```sql
-- tables.cql: Design tables around query patterns (partition key + clustering key)
-- Rule: one table per query pattern
-- Users by email (partition key: email)
CREATE TABLE users (
email text PRIMARY KEY,
name text,
created_at timestamp
);
-- Posts by user, ordered by time (partition: user_id, clustering: created_at DESC)
CREATE TABLE posts_by_user (
user_id uuid,
created_at timestamp,
post_id uuid,
title text,
body text,
PRIMARY KEY (user_id, created_at)
) WITH CLUSTERING ORDER BY (created_at DESC);
-- Time-series: sensor readings bucketed by day
CREATE TABLE sensor_readings (
sensor_id text,
day text,
reading_time timestamp,
value double,
PRIMARY KEY ((sensor_id, day), reading_time)
) WITH CLUSTERING ORDER BY (reading_time DESC);
```
## CRUD Operations
```sql
-- crud.cql: Basic insert, select, update, delete
INSERT INTO users (email, name, created_at)
VALUES ('[email protected]', 'Alice', toTimestamp(now()));
SELECT * FROM users WHERE email = '[email protected]';
-- Query with partition and clustering key
SELECT * FROM posts_by_user
WHERE user_id = 550e8400-e29b-41d4-a716-446655440000
AND created_at > '2026-01-01'
LIMIT 20;
UPDATE users SET name = 'Alice Smith' WHERE email = '[email protected]';
DELETE FROM users WHERE email = '[email protected]';
-- Batch for atomicity within a partition
BEGIN BATCH
INSERT INTO posts_by_user (user_id, created_at, post_id, title) VALUES (?, ?, ?, ?);
UPDATE user_stats SET post_count = post_count + 1 WHERE user_id = ?;
APPLY BATCH;
```
## Node.js Driver
```javascript
// db.js: Cassandra client with DataStax Node.js driver
const { Client, types } = require('cassandra-driver');
const client = new Client({
contactPoints: ['localhost'],
localDataCenter: 'datacenter1',
keyspace: 'myapp',
queryOptions: { consistency: types.consistencies.localQuorum },
});
async function main() {
await client.connect();
// Insert
await client.execute(
'INSERT INTO users (email, name, created_at) VALUES (?, ?, ?)',
['[email protected]', 'Bob', new Date()],
{ prepare: true }
);
// Query
const result = await client.execute(
'SELECT * FROM users WHERE email = ?',
['[email protected]'],
{ prepare: true }
);
console.log(result.rows[0]);
// Paginated query
const query = 'SELECT * FROM posts_by_user WHERE user_id = ?';
for await (const row of client.stream(query, [userId], { prepare: true })) {
console.log(row.title);
}
await client.shutdown();
}
main().catch(console.error);
```
## Python Driver
```python
# app.py: Cassandra with Python DataStax driver
from cassandra.cluster import Cluster
from cassandra.query import SimpleStatement, ConsistencyLevel
cluster = Cluster(['localhost'])
session = cluster.connect('myapp')
# Insert
session.execute(
"INSERT INTO users (email, name, created_at) VALUES (%s, %s, toTimestamp(now()))",
('[email protected]', 'Alice')
)
# Query with consistency level
stmt = SimpleStatement(
"SELECT * FROM users WHERE email = %s",
consistency_level=ConsistencyLevel.LOCAL_QUORUM
)
row = session.execute(stmt, ('[email protected]',)).one()
print(row.name)
cluster.shutdown()
```
## Replication and Consistency
```text
Consistency Levels:
- ONE: Fast, low consistency. Good for logs/metrics.
- QUORUM: Majority of replicas. Balanced read/write.
- LOCAL_QUORUM: Majority in local datacenter. Best for multi-DC.
- ALL: All replicas must respond. Slowest, strongest consistency.
Rule of thumb: Write CL + Read CL > Replication Factor = strong consistency
Example: RF=3, Write=QUORUM(2), Read=QUORUM(2) → 2+2 > 3 ✓
```
## Operations
```bash
# nodetool.sh: Common operational commands
# Check cluster status
docker exec cassandra nodetool status
# Check ring token distribution
docker exec cassandra nodetool ring
# Repair data (run regularly)
docker exec cassandra nodetool repair myapp
# Compact SSTables
docker exec cassandra nodetool compact myapp posts_by_user
# Take a snapshot backup
docker exec cassandra nodetool snapshot myapp -t backup_20260219
```
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.