Skip to content

Instantly share code, notes, and snippets.

View beccam's full-sized avatar

Rebecca Mills beccam

View GitHub Profile
@beccam
beccam / GettingStarted.java
Created June 27, 2014 19:54
Getting Started with Apache Cassandra and Java
import com.datastax.driver.core.*;
public class GettingStarted {
public static void main(String[] args) {
Cluster cluster;
Session session;
package com.datastax.quickstart;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.*;
import java.net.InetSocketAddress;
public class GettingStarted {
public static void main(String[] args) {
@beccam
beccam / quickstart.js
Last active May 31, 2019 11:13
Demo CRUD application with Node.js
const cassandra = require('cassandra-driver');
// TO DO: Fill in your own host and data center
const client = new cassandra.Client({
contactPoints: ['127.0.0.1'],
localDataCenter: 'datacenter1',
keyspace: 'demo'
});
function insertUser(lastname, age, city, email, firstname) {
@beccam
beccam / quickstart.cpp
Created July 9, 2019 20:07
A basic C++ demo CRUD application using the DataStax C/C++ Driver for Apache Cassandra
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cassandra.h"
struct Users_ {
const char* lastname;
cass_int32_t age;
@beccam
beccam / quickstart.c
Last active July 17, 2019 12:20
A basic C demo CRUD application using the DataStax C/C++ Driver for Apache Cassandra.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cassandra.h>
struct Users_ {
const char* lastname;
cass_int32_t age;
const char* city;
@beccam
beccam / Program.cs
Last active October 23, 2019 15:00
A basic C#/.NET demo CRUD application using the DataStax C# Driver for Apache Cassandra.
using Cassandra;
using System.Linq;
using System;
namespace QuickStart
{
class Program
{
static void Main(string[] args)
{
@beccam
beccam / GettingStarted.js
Last active April 22, 2020 06:06
Getting Started with Apace Cassandra and the Datastax Node.js Driver
var cassandra = require('cassandra-driver');
var async = require('async');
var client = new cassandra.Client({contactPoints: ['127.0.0.1'], keyspace: 'demo'});
// Use async series to run functions in serial (one after another)
async.series([
// Insert Bob
function (callback) {
client.execute("INSERT INTO users (lastname, age, city, email, firstname) VALUES ('Jones', 35, 'Austin', 'bob@example.com', 'Bob')", function (err, result) {
@beccam
beccam / GettingStarted.go
Created June 30, 2014 16:14
Getting Started with Apace Cassandra and Go
package main
import (
"fmt"
"log"
"github.com/gocql/gocql"
)
func main() {
@beccam
beccam / astra_connect.py
Last active August 5, 2020 13:54
Connect to Astra with the Python Driver
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
def set_user(session, lastname, age, city, email, firstname):
# TO DO: execute SimpleStatement that inserts one user into the table
session.execute("INSERT INTO users (lastname, age, city, email, firstname) VALUES (%s,%s,%s,%s,%s)", [lastname, age, city, email, firstname])
def get_user(session, lastname):
# TO DO: execute SimpleStatement that retrieves one user from the table
# TO DO: print firstname and age of user
@beccam
beccam / AstraConnect.cs
Last active August 6, 2020 14:09
Connect to Astra with the DataStax C# driver
using Cassandra;
using System.Linq;
using System;
namespace QuickStart
{
class AstraConnect
{
static void Main(string[] args)
{