https://github.com/jhhtaylor/cassandra-with-go
Demo application in Go interfacing with local Cassandra. Showcases interaction with the 'demo' keyspace, handling user data insertion and retrieval in the 'users' table.
https://github.com/jhhtaylor/cassandra-with-go
cassandra database go
Last synced: 2 months ago
JSON representation
Demo application in Go interfacing with local Cassandra. Showcases interaction with the 'demo' keyspace, handling user data insertion and retrieval in the 'users' table.
- Host: GitHub
- URL: https://github.com/jhhtaylor/cassandra-with-go
- Owner: jhhtaylor
- License: mit
- Created: 2023-08-30T17:07:54.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-30T17:20:58.000Z (almost 3 years ago)
- Last Synced: 2026-04-30T12:34:11.695Z (2 months ago)
- Topics: cassandra, database, go
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cassandra-with-go
In `cassandra-with-go/` directory
### **Step 1: Set up Cassandra**
1.1 **Install Cassandra**:
If you're using macOS, the easiest way is with Homebrew:
```bash
brew install cassandra
```
1.2 **Start Cassandra**:
```bash
cassandra -f
```
1.3 **Cassandra CQL Shell**:
You can interact with Cassandra using the CQL (Cassandra Query Language) shell. To start it, just type:
```bash
cqlsh
```
### **Step 2: Create a Sample Database**
Using the CQL shell, let's create a simple keyspace and table:
```
cqlCopy code
CREATE KEYSPACE demo WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
USE demo;
CREATE TABLE users (
id UUID PRIMARY KEY,
name TEXT,
age INT
);
```
### **Step 3: Set Up Go and Cassandra Go Driver**
3.1 **Install Go Driver**:
You'll need the Go driver for Cassandra. To get it, run:
```bash
go get github.com/gocql/gocql
```
---
### **Step 4: Run Go Program**
```bash
go run main.go
```
If everything goes as planned, the output will indicate that a user "Alice" with age 30 has been added and then retrieved from the Cassandra users table.