diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 0000000..f8e49f2 --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,7 @@ +FROM gitpod/workspace-full + +# Install custom tools, runtimes, etc. +# For example "bastet", a command-line tetris clone: +# RUN brew install bastet +# +# More information: https://www.gitpod.io/docs/config-docker/ diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..475c7d9 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,6 @@ +image: + file: .gitpod.Dockerfile + +tasks: + - init: 'echo "TODO: Replace with init/build command"' + command: 'echo "TODO: Replace with command to start project"' diff --git a/README.md b/README.md index 303b1ad..a266756 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/LeilaGhods/Samples) + # Samples This is my sample code diff --git a/crud_python/db_connection.py b/crud_python/db_connection.py new file mode 100644 index 0000000..485ba83 --- /dev/null +++ b/crud_python/db_connection.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +from cassandra.cluster import Cluster +from cassandra.auth import PlainTextAuthProvider + +# This is the Zip file you downloaded +SECURE_CONNECT_BUNDLE = '/workspace/workshop-crud-with-python-and-node/crud-python/creds.zip' +# This is the username, recommended value was SUser +USERNAME = "SUser"; +# This is the password, recommended value was SPassword1 +PASSWORD = "SPassword1"; +# This is the keyspace name, recommended value was spacecraft +KEYSPACE = "spacecraft"; + +class Connection: + def __init__(self): + self.secure_connect_bundle=SECURE_CONNECT_BUNDLE + self.path_to_creds='' + self.cluster = Cluster( + cloud={ + 'secure_connect_bundle': self.secure_connect_bundle + }, + auth_provider=PlainTextAuthProvider(USERNAME, PASSWORD) + ) + self.session = self.cluster.connect(KEYSPACE) + def close(self): + self.cluster.shutdown() + self.session.shutdown()