From 5433407a11a350d484a8dba9d1ec067c66c53256 Mon Sep 17 00:00:00 2001 From: Umar Farooq Ghumman Date: Wed, 7 Feb 2024 11:26:12 -0600 Subject: [PATCH] Create conn.ipynb Create jupyter notebook page to allow users to connect without any code. --- docker-verticapy/connection/conn.ipynb | 331 +++++++++++++++++++++++++ 1 file changed, 331 insertions(+) create mode 100644 docker-verticapy/connection/conn.ipynb diff --git a/docker-verticapy/connection/conn.ipynb b/docker-verticapy/connection/conn.ipynb new file mode 100644 index 00000000..8f9c1320 --- /dev/null +++ b/docker-verticapy/connection/conn.ipynb @@ -0,0 +1,331 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "739353e9-44cd-4dbb-8891-f1dea998067f", + "metadata": {}, + "outputs": [], + "source": [ + "from ipywidgets import interact, interactive, fixed, interact_manual\n", + "import ipywidgets as widgets" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "8ed8016c-dacf-437d-af27-7005b66f6739", + "metadata": {}, + "outputs": [], + "source": [ + "host = widgets.Text(placeholder = \"Enter Host (default is 'verticadb')\")\n", + "port = widgets.Text(placeholder = \"Enter Port (default is 5433)\")\n", + "user = widgets.Text(placeholder = \"Enter User Name (default is 'dbadmin')\")\n", + "password = widgets.Text(placeholder = \"Enter Password (default is Empty)\")\n", + "database = widgets.Text(placeholder = \"Enter Database (default is 'demo')\")\n", + "name = widgets.Text(placeholder = \"Enter Name (default is 'VerticaDSN')\")\n", + "backup_server_node = [\"localhost\"]" + ] + }, + { + "cell_type": "markdown", + "id": "44057b5a-42f9-4230-8e5d-81ceae1bbe79", + "metadata": {}, + "source": [ + "## Please Enter Host:" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "1dcd207c-f1da-45fc-9459-ac3572854586", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "83e21b5858e948fc8bd999b0a60711cf", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Text(value='', placeholder=\"Enter Host (default is 'verticadb')\")" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "host" + ] + }, + { + "cell_type": "markdown", + "id": "a0c1f0a3-7c1a-42fe-9f8b-5b0a1b28de5e", + "metadata": {}, + "source": [ + "## Please Enter Port:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "2e7854f5-daf7-4ade-bbb9-bd088057156b", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "2b97ba3f7a3c46b9bafaf992a0d20e4e", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Text(value='', placeholder='Enter Port (default is 5433)')" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "port" + ] + }, + { + "cell_type": "markdown", + "id": "98572ad4-80d0-4ad1-a20d-9e03841c12b6", + "metadata": {}, + "source": [ + "## Please Enter Username:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "58e4fc79-d0bf-49ab-acef-2027aabb7560", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "f1550dc18fa446b18b7382f2a618ec72", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Text(value='', placeholder=\"Enter User Name (default is 'dbadmin')\")" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "user" + ] + }, + { + "cell_type": "markdown", + "id": "9bca8992-ae00-4ed7-bff3-5f9906db0ef0", + "metadata": {}, + "source": [ + "## Please Enter Password:" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "44865d1f-f343-4854-b1da-208877d8480a", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d4c5d4d053014bc19bf8827bf2569dde", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Text(value='', placeholder='Enter Password (default is Empty)')" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "password" + ] + }, + { + "cell_type": "markdown", + "id": "17302419-90bb-46b3-ac0f-fdb902d4985b", + "metadata": {}, + "source": [ + "## Please Enter Database" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "4a6e10ae-cec4-48d1-87fd-4ec1a5b13c9b", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8f4487d4ed68427ebe65d476ebe2cf97", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Text(value='', placeholder=\"Enter Database (default is 'demo')\")" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "database" + ] + }, + { + "cell_type": "markdown", + "id": "ff13f2c5-67e4-45de-be1d-67235a0516f4", + "metadata": {}, + "source": [ + "## Please Enter Name For The Connection" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "52c5b148-c302-4ce4-98db-d43fbd139382", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "aaea381af6ff4daabafa56f4b7a51f0f", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Text(value='', placeholder=\"Enter Name (default is 'VerticaDSN')\")" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "name" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "a70eb307-19eb-4ecd-866f-54864d981032", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.12/site-packages/vertica_highcharts/highcharts/highcharts.py:11: UserWarning: future library does not support Python 3.12 yet. The import is skipped.\n", + " warnings.warn('future library does not support Python 3.12 yet. The import is skipped.')\n", + "/usr/local/lib/python3.12/site-packages/vertica_highcharts/highmaps/highmaps.py:11: UserWarning: future library does not support Python 3.12 yet. The import is skipped.\n", + " warnings.warn('future library does not support Python 3.12 yet. The import is skipped.')\n", + "/usr/local/lib/python3.12/site-packages/vertica_highcharts/highstock/highstock.py:11: UserWarning: future library does not support Python 3.12 yet. The import is skipped.\n", + " warnings.warn('future library does not support Python 3.12 yet. The import is skipped.')\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "4d8f74df85a04ed88c8a5b1b4abb6728", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Button(description='Create a Connection', style=ButtonStyle())" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "a116db0300ac439d903e9ca8e5ff7194", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import verticapy as vp\n", + "from IPython.display import display\n", + "button = widgets.Button(description=\"Create a Connection\")\n", + "output = widgets.Output()\n", + "display(button, output)\n", + "\n", + "\n", + "\n", + "def on_button_clicked(b):\n", + " with output:\n", + " conn_info = {\n", + " 'host': host.value if host.value else \"verticadb\", \n", + " 'port': port.value if port.value else 5433,\n", + " 'user': user.value if user.value else \"dbadmin\",\n", + " 'password': password.value if password.value else \"\",\n", + " 'database': database.value if database.value else \"demo\",\n", + " }\n", + " vp.new_connection(\n", + " conn_info,\n", + " name = name.value if name.value else \"VerticaDSN\",\n", + " auto = True,\n", + " overwrite = True,)\n", + " print(\"Connected to:\", vp.current_connection())\n", + "\n", + "button.on_click(on_button_clicked)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "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.12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}