Skip to content

Instantly share code, notes, and snippets.

Avatar

Rebecca Mills beccam

View GitHub Profile
@beccam
beccam / AstraConnect.java
Last active Aug 6, 2020
Connect to Astra with the DataStax Java driver
View AstraConnect.java
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.*;
import java.nio.file.Paths;
public class AstraConnect {
public static void main(String[] args) {
// TO DO: Fill in your own host, port, and data center
@beccam
beccam / AstraConnect.cs
Last active Aug 6, 2020
Connect to Astra with the DataStax C# driver
View AstraConnect.cs
using Cassandra;
using System.Linq;
using System;
namespace QuickStart
{
class AstraConnect
{
static void Main(string[] args)
{
@beccam
beccam / astra-connect.js
Last active Aug 6, 2020
Connect to Astra with the DataStax Node.js driver
View astra-connect.js
const cassandra = require('cassandra-driver');
const client = new cassandra.Client({
cloud: { secureConnectBundle: 'path/to/secure-connect-DATABASE_NAME.zip' },
credentials: { username: 'username', password: 'password' }
keyspace: 'demo'
});
function createTable(){
@beccam
beccam / astra_connect.py
Last active Aug 5, 2020
Connect to Astra with the Python Driver
View astra_connect.py
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 / quickstart.c
Last active Jul 17, 2019
A basic C demo CRUD application using the DataStax C/C++ Driver for Apache Cassandra.
View quickstart.c
#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 / quickstart.cpp
Created Jul 9, 2019
A basic C++ demo CRUD application using the DataStax C/C++ Driver for Apache Cassandra
View quickstart.cpp
#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.js
Last active May 31, 2019
Demo CRUD application with Node.js
View quickstart.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.py
Last active May 30, 2019
A basic Python demo CRUD application using the DataStax Python Driver for Apache Cassandra.
View quickstart.py
from cassandra.cluster import Cluster
def create_connection():
# TO DO: Fill in your own contact point
cluster = Cluster(['127.0.0.1'])
return cluster.connect('demo')
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])
@beccam
beccam / Program.cs
Last active Oct 23, 2019
A basic C#/.NET demo CRUD application using the DataStax C# Driver for Apache Cassandra.
View Program.cs
using Cassandra;
using System.Linq;
using System;
namespace QuickStart
{
class Program
{
static void Main(string[] args)
{
View GettingStarted.java
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) {
You can’t perform that action at this time.