ManagedkdbInsights/boto/list_databases.ipynb (123 lines of code) (raw):
{
"cells": [
{
"cell_type": "markdown",
"id": "e13084db-c69f-4e70-aa79-acfd2159093a",
"metadata": {},
"source": [
"# List Databases"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3698017d-42ed-4280-afa1-723f19ae398c",
"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 *"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ed241efe-523e-4d2f-8e1b-94a09adf42e7",
"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": "markdown",
"id": "6b7294c7-d9a3-4fb2-b671-12ead3e17e83",
"metadata": {},
"source": [
"# Databases"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4d600940-ffbf-41a2-8df0-a7a7fc0b594b",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"db_list = list_kx_databases(client, environmentId=ENV_ID)\n",
"db_list = sorted(db_list, key=lambda d: d['databaseName']) \n",
"\n",
"db_pdf = pd.DataFrame.from_dict(db_list).style.hide(axis='index')\n",
"display(db_pdf)"
]
},
{
"cell_type": "markdown",
"id": "57a48a33-6426-42c1-933e-7cc92990e3e2",
"metadata": {},
"source": [
"# Databases and Changesets "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7078c851-337b-44b9-8942-9dc867771972",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"for d in db_list:\n",
" db_name = d['databaseName']\n",
" dump_database(client, environmentId=ENV_ID, databaseName=db_name)\n",
"\n",
"print( f\"Last Run: {datetime.datetime.now()}\" )"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7ab440c1-99c8-45b2-b465-2baa9958f2cf",
"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
}