Skip to content

Instantly share code, notes, and snippets.

@oldarmyc
oldarmyc / oracle.py
Created December 10, 2018 18:21
Oracle example connection
"""
In order to connect to oracle the following packages will need to be installed from conda.
cx_oracle
oracle-instantclient
libaio
"""
# Import the library needed
import cx_Oracle
@oldarmyc
oldarmyc / mariadb.py
Created December 10, 2018 18:23
MariaDB example connection
"""
To connect to mariadb you would need to conda install the mysql-connector-python package
conda install -c anaconda mysql-connector-python
"""
import mysql.connector as mariadb
import json
# Read the credentials from secret
@oldarmyc
oldarmyc / neo4j.py
Created December 10, 2018 18:25
Neo4j example connection
"""
To start working with Neo4j you would need to pip install the package.
pip install neo4j
Documentation is located here:
https://neo4j.com/docs/api/python-driver/current/
"""
from neo4j import GraphDatabase
@oldarmyc
oldarmyc / mysql.py
Created December 10, 2018 18:28
MySQL example connection
"""
To connect to mysql you would need to conda install the mysql-connector-python conda package
conda install -c anaconda mysql-connector-python
"""
import mysql.connector as mysql
import json
# Get credentials from kubernetes. The credentials were setup as a dictionary
@oldarmyc
oldarmyc / cassandra.py
Created December 10, 2018 19:06
Cassandra example connection
"""
Import the cassandra libraries that will be needed to connect to the cassandra cluster.
Note: Currently the cassandra-driver is only available for python 2.7 on conda-forge
Example install of package
conda install -c conda-forge cassandra-driver
"""
from cassandra.auth import PlainTextAuthProvider
from cassandra.cluster import Cluster
@oldarmyc
oldarmyc / db2_example.py
Created December 13, 2018 19:09
DB2 example
"""
Import the ibm_db library
Will need to ensure that gcc is installed in the project environment as well. To do this will need to
go to the environment terminal and install gcc through yum using the following command.
sudo yum install gcc -y
After gcc installs you can install the pip package ibm_db using the following command.
@oldarmyc
oldarmyc / vertica_example.py
Created December 17, 2018 17:30
Vertica Example
"""
To install the vertica driver would need to install via conda
conda install -c conda-forge vertica-python
Import the vertica python library
"""
import vertica_python
import json
@oldarmyc
oldarmyc / redis.py
Created December 19, 2018 17:52
Redis example
"""
Connecting to Redis server
Install the pip package for python to use for connecting to Redis
pip install redis
"""
# Import the library
import redis
@oldarmyc
oldarmyc / couchbase.py
Created December 20, 2018 00:27
Couchbase example
"""
To get started will have to install a few packages to get things running
# Download the release RPM from couchbase that sets up the couchbase repositories
wget http://packages.couchbase.com/releases/couchbase-release/couchbase-release-1.0-4-x86_64.rpm
# Install the RPM using yum
sudo yum localinstall couchbase-release-1.0-4-x86_64.rpm -y
# Install the needed packages required for the pip package install
@oldarmyc
oldarmyc / mldb.py
Created December 21, 2018 20:16
MLDB Example
"""
MLDB example using the pymldb library
Note: pymldb only works in python 2
The pip packages you would need to install and use the are pymldb and tqdm
pip install pymldb tqdm
"""
# Import the library