ManagedkdbInsights/boto/get_connectionstrings.ipynb (130 lines of code) (raw):
{
"cells": [
{
"cell_type": "markdown",
"id": "28bea13b-67bd-4a0e-8eab-3b8ffd37259e",
"metadata": {},
"source": [
"# TAQ: Connection Strings\n",
"Get the Connection strings Clusters"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0d5f1d4a-ed45-44e3-bf75-9bdb75fcddbb",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import os\n",
"import boto3\n",
"import json\n",
"import datetime\n",
"\n",
"from managed_kx import *\n",
"from env import *\n",
"\n",
"CLUSTER_NAMES=[ \n",
" \"cluster_welcomedb\",\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3cfe7d89-9f5d-4ceb-ac8c-1f5054a6f15a",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Using credentials and create service client\n",
"session = boto3.Session()\n",
"\n",
"# create finspace client\n",
"client = session.client(service_name='finspace')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1d9b2d5a-19e9-44f9-8c38-ee8600453e87",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# get the connection strings\n",
"conns = {}\n",
"\n",
"for c in CLUSTER_NAMES:\n",
" try:\n",
" conn_str = get_kx_connection_string(client, environmentId=ENV_ID, clusterName=c, userName=KDB_USERNAME, boto_session=session)\n",
" conns[c] = conn_str\n",
" except:\n",
" continue"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a9a896d-466e-4321-86c4-a54e76d7997a",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"print(\"Paste below into q \"+\"=\"*80)\n",
"\n",
"for cluster, conn_str in conns.items():\n",
" print(f\"\"\"\n",
"/ Cluster: {cluster}\n",
"hdb_conn:\"{conn_str}\"\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "86f33240-bb12-49f3-8d9c-5783c25eb182",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"print( f\"Last Run: {datetime.datetime.now()}\" )"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d71daf7b-510b-4c0d-b285-360eb1c19533",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "conda_python3",
"language": "python",
"name": "conda_python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}