Last active
May 11, 2022 03:50
-
-
Save iSignal/1c8cb0741e54650acc7672ca1a9d2e2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install yb-cassandra-driver to be able to import cassandra.cluster | |
from cassandra.cluster import Cluster, Session | |
from ssl import SSLContext, PROTOCOL_TLS, CERT_REQUIRED | |
import os | |
import sys | |
hostname = sys.argv[1] | |
ssl_context = SSLContext(PROTOCOL_TLS) | |
ssl_context.load_verify_locations(cafile=os.getenv('SSL_CERTFILE')) | |
ssl_context.verify_mode = CERT_REQUIRED | |
ssl_context.check_hostname = True | |
ssl_options = {'server_hostname': hostname} | |
cluster = Cluster([hostname], ssl_context=ssl_context, ssl_options=ssl_options) | |
session = cluster.connect() | |
print(session.execute("SELECT * FROM system.local;").one()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment