This guide will get you up and running with Accord transactions in minutes. We'll cover setup, basic usage, and your first transaction.
- Docker installed (for single-node testing)
- OR Homebrew (for multi-node setup)
- Basic familiarity with CQL
# Pull and run the container
docker pull pmcfadin/cassandra-accord
docker run -d --name cassandra-accord -p 9042:9042 pmcfadin/cassandra-accord
# Connect with cqlsh
docker exec -it cassandra-accord ./bin/cqlsh
# Install easy-cass-lab
brew tap rustyrazorblade/rustyrazorblade
brew install easy-cass-lab
# Create a new cluster
mkdir my-cluster && cd my-cluster
easy-cass-lab init -c 3 -s 1 mycluster
easy-cass-lab up
Let's create a simple inventory management system:
-- Create a table with transactions enabled
CREATE TABLE demo.products (
item text,
inventory_count decimal,
PRIMARY KEY (item)
) WITH transactional_mode = 'full';
-- Insert initial inventory
INSERT INTO demo.products(item, inventory_count)
VALUES ('PlayStation 5', 100);
-- Run a transaction to update inventory
BEGIN TRANSACTION
UPDATE demo.products
SET inventory_count -= 1
WHERE item='PlayStation 5';
COMMIT TRANSACTION;
-- Verify the result
SELECT * FROM demo.products WHERE item='PlayStation 5';
- Bank Transfer
BEGIN TRANSACTION
UPDATE accounts SET balance -= 100 WHERE user_id = 'alice';
UPDATE accounts SET balance += 100 WHERE user_id = 'bob';
COMMIT TRANSACTION;
- User Registration
BEGIN TRANSACTION
LET existing = (SELECT email FROM users WHERE email = '[email protected]');
IF existing IS NULL THEN
INSERT INTO users(id, email) VALUES (uuid(), '[email protected]');
END IF
COMMIT TRANSACTION;
- Explore more Use Cases
- Learn about Transaction Patterns
- Read about Performance Tuning
- Join our Discord community
- Check out the Github Discussions in the repository
- Check our Troubleshooting guide
- Ask in our Discord channel
- Review Common Issues