skills/convex-db/SKILL.md
Use Convex DB — a lattice-backed SQL database. Use when helping users write queries, connect via JDBC or PostgreSQL clients, create tables, insert/query data, or use the direct lattice API.
npx skillsauth add Convex-Dev/convex convex-dbInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Convex DB provides SQL access over lattice data. Connect via JDBC, PostgreSQL wire protocol, or the direct lattice API.
Reference: convex-db/README.md for full documentation including replication, PostgreSQL server setup, and architecture details.
// In-memory
Connection conn = DriverManager.getConnection("jdbc:convex:mydb");
// Persistent (Etch-backed, survives restarts)
Connection conn = DriverManager.getConnection("jdbc:convex:file:/data/mydb.etch");
Driver auto-registers via ServiceLoader. Class: convex.db.jdbc.ConvexDriver
# Start the PG server
java -cp convex-db.jar convex.db.psql.PgServer -p 5432 -d mydb
# Then connect with any PG client
psql -h localhost -p 5432 -d mydb
import psycopg2
conn = psycopg2.connect(host="localhost", port=5432, dbname="mydb")
CREATE TABLE users (id, name, email)
Column 0 (first column) is always the primary key. Types are inferred from inserted data.
INSERT INTO users VALUES (1, 'Alice', '[email protected]')
For bulk loading, use prepared statements with batch:
PreparedStatement ps = conn.prepareStatement("INSERT INTO users VALUES (?, ?, ?)");
for (int i = 0; i < 10000; i++) {
ps.setLong(1, i);
ps.setString(2, "Name-" + i);
ps.setString(3, "email-" + i + "@example.com");
ps.addBatch();
}
ps.executeBatch();
-- Point lookup (fast — O(log n) via PK index pushdown)
SELECT * FROM users WHERE id = 1
-- Filtering, sorting, pagination
SELECT name, email FROM users WHERE name LIKE 'A%' ORDER BY name LIMIT 10
-- Joins
SELECT c.name, o.amount
FROM customers c INNER JOIN orders o ON c.id = o.customer_id
-- Aggregations
SELECT department, COUNT(*), AVG(salary)
FROM employees GROUP BY department HAVING COUNT(*) > 5
CREATE TABLE, DROP TABLEINSERT, UPDATE, DELETESELECT, WHERE, ORDER BY, LIMIT, OFFSETINNER JOIN, LEFT JOIN, RIGHT JOIN, CROSS JOINGROUP BY, HAVING, COUNT, SUM, AVG, MIN, MAXCASE WHEN, COALESCE, CAST, BETWEEN, IN, LIKE, IS NULLABS, FLOOR, CEIL, SQRT, UPPER, LOWER, TRIM, SUBSTRING, LENGTH, CONCATconn.setAutoCommit(false);
stmt.execute("INSERT INTO users VALUES (2, 'Bob', '[email protected]')");
stmt.execute("UPDATE users SET email = '[email protected]' WHERE id = 1");
conn.commit(); // atomic merge — all changes become visible
// or conn.rollback() to discard
| SQL Type | CVM Type | Notes | |----------|----------|-------| | BIGINT / INTEGER | CVMLong | 64-bit signed integer | | DOUBLE | CVMDouble | 64-bit float | | VARCHAR | AString | Unicode string | | BOOLEAN | CVMBool | true/false | | VARBINARY / BLOB | ABlob | Binary data | | TIMESTAMP | CVMLong | Milliseconds since epoch | | ANY | ACell | Dynamic type |
For programmatic access without SQL overhead:
ConvexDB cdb = ConvexDB.create();
SQLDatabase db = cdb.database("mydb");
// Create table
db.tables().createTable("users", new String[]{"id", "name", "email"});
// Insert
db.tables().insert("users", 1, "Alice", "[email protected]");
// Point lookup
AVector<ACell> row = db.tables().selectByKey("users", 1);
// Scan all
Index<ABlob, AVector<ACell>> all = db.tables().selectAll("users");
// Delete
db.tables().deleteByKey("users", 1);
WHERE id = ?) for point queries — O(log n) via index pushdown# Build (requires Convex core installed first)
cd convex && mvn clean install -DskipTests -pl convex-db -am
# Run tests
cd convex && mvn test -pl convex-db
devops
Deploy an actor (smart contract) to the Convex network. Use when the user wants to create a new on-chain actor with exported functions.
tools
Transfer CVM coins or fungible tokens between Convex accounts. Use when the user wants to send coins or tokens to another account.
data-ai
Execute a CVM transaction on the Convex network. Use when the user wants to modify on-chain state, call actor functions, or define values.
testing
Create and manage fungible tokens on Convex. Use when the user wants to create a new token, check token balances, or manage token supply.