From 3a2b9b1b2ac93fe414c8a7d2d1888ef9eb47607d Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Tue, 10 Jan 2023 23:58:17 +0100 Subject: [PATCH] Removed the jupyter connector. --- JupyterConnector.ipynb | 288 ----------------------------------------- 1 file changed, 288 deletions(-) delete mode 100644 JupyterConnector.ipynb diff --git a/JupyterConnector.ipynb b/JupyterConnector.ipynb deleted file mode 100644 index dc7c04b..0000000 --- a/JupyterConnector.ipynb +++ /dev/null @@ -1,288 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "f536eab6-2776-4535-972a-3ece6be99b3a", - "metadata": {}, - "outputs": [], - "source": [ - "import warnings\n", - "\n", - "warnings.simplefilter(action=\"ignore\", category=FutureWarning)" - ] - }, - { - "cell_type": "markdown", - "id": "f6597a28-a4fc-46bb-a9b2-3cafbc944ef5", - "metadata": {}, - "source": [ - "# Start here\n", - "### Install couchbase and pandas with specified versions\n", - "The cell below installs the couchbase python package and pandas." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "0c9dbddc-f5f5-4f58-a2e2-dfff0faf517f", - "metadata": {}, - "outputs": [], - "source": [ - "!pip install couchbase==4.1.1 -q\n", - "!pip install pandas==1.5.2 -q" - ] - }, - { - "cell_type": "markdown", - "id": "8f41454c-0bf0-4e53-992b-34fb47bf7dd1", - "metadata": {}, - "source": [ - "Import the the classes necessary to run the couchbase connector." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "5c4c7d02-c06b-49c3-a6e6-9819e9eae44b", - "metadata": {}, - "outputs": [], - "source": [ - "import pandas as pd\n", - "from couchbase.cluster import Cluster\n", - "from couchbase.auth import PasswordAuthenticator\n", - "\n", - "from couchbase.options import ClusterOptions, QueryOptions" - ] - }, - { - "cell_type": "markdown", - "id": "2e5173f8-7c64-40f4-8fbe-e3bf28ad96a3", - "metadata": {}, - "source": [ - "Connect to the cluster select the sample bucket and connect to the default collection." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "66ada60d-8a49-473b-bc38-a40999ba761a", - "metadata": {}, - "outputs": [], - "source": [ - "cluster = Cluster.connect(\n", - " \"couchbase://couchbase1\",\n", - " ClusterOptions(\n", - " PasswordAuthenticator(\"Administrator\", \"some-pw-that-is-better-than-this!\")\n", - " ),\n", - ")\n", - "bucket = cluster.bucket(\"travel-sample\")\n", - "\n", - "# get a reference to the default collection\n", - "cb_coll = bucket.default_collection()" - ] - }, - { - "cell_type": "markdown", - "id": "3dbc2840-9793-4a92-802b-78d0b333e632", - "metadata": {}, - "source": [ - "Acces a document by key." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "5e5fd8c8-200f-4857-b63d-1172b842f11c", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'id': 10,\n", - " 'type': 'airline',\n", - " 'name': '40-Mile Air',\n", - " 'iata': 'Q5',\n", - " 'icao': 'MLA',\n", - " 'callsign': 'MILE-AIR',\n", - " 'country': 'United States'}" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# get a document by key\n", - "result = cb_coll.get(\"airline_10\")\n", - "result.value" - ] - }, - { - "cell_type": "markdown", - "id": "e818c095-e2d9-40c7-9234-ceddcb27cddb", - "metadata": {}, - "source": [ - "The Querry language contains a \n", - "If a hyphen is used please use a pair of \\` to surround the name using a hyphen." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "8eb6d0be-9fc0-4c89-ad18-801c0349d5cc", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "RangeIndex: 1968 entries, 0 to 1967\n", - "Data columns (total 9 columns):\n", - " # Column Non-Null Count Dtype \n", - "--- ------ -------------- ----- \n", - " 0 airportname 1968 non-null object\n", - " 1 city 1968 non-null object\n", - " 2 country 1968 non-null object\n", - " 3 faa 1709 non-null object\n", - " 4 geo 1968 non-null object\n", - " 5 icao 1687 non-null object\n", - " 6 id 1968 non-null int64 \n", - " 7 type 1968 non-null object\n", - " 8 tz 1968 non-null object\n", - "dtypes: int64(1), object(8)\n", - "memory usage: 138.5+ KB\n" - ] - } - ], - "source": [ - "result = cluster.query(\n", - " \"\"\"\n", - " SELECT airport.* \n", - " FROM `travel-sample`.inventory.airport airport\n", - " \"\"\",\n", - " QueryOptions(metrics=True),\n", - ")\n", - "df = pd.DataFrame(result)\n", - "df.info()" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "id": "c1237c23-2ab4-4fa0-9895-0691c20827b6", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\\begin{tabular}{llll}\n", - "\\toprule\n", - "{} & airportname & city & country \\\\\n", - "\\midrule\n", - "\\textbf{4877} & London Heliport & London & United Kingdom \\\\\n", - "\\textbf{4289} & London St Pancras & London & United Kingdom \\\\\n", - "\\textbf{3411} & Stansted & London & United Kingdom \\\\\n", - "\\textbf{6457} & London - Kings Cross & London & United Kingdom \\\\\n", - "\\textbf{8759} & Charles De Gaulle & Paris & France \\\\\n", - "\\bottomrule\n", - "\\end{tabular}\n", - "\n" - ] - } - ], - "source": [ - "result = cluster.query(\n", - " \"\"\"\n", - " SELECT airport.airportname, airport.city, airport.country \n", - " FROM `travel-sample`.inventory.airport airport INNER JOIN `travel-sample`.inventory.landmark landmark on airport.city = landmark.city\n", - " \"\"\",\n", - " QueryOptions(metrics=True),\n", - ")\n", - "print(pd.DataFrame(result).sample(5).to_latex(bold_rows=True))" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "a4cc7ef5-511e-4709-9d82-e1c20238f173", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\\begin{tabular}{lllll}\n", - "\\toprule\n", - "{} & airportname & city & country & name \\\\\n", - "\\midrule\n", - "\\textbf{443 } & Edinburgh & Edinburgh & United Kingdom & Murrayfield Ice Rink \\\\\n", - "\\textbf{1487} & Luton & London & United Kingdom & The Phoenix \\\\\n", - "\\textbf{3620} & Paddington Station & London & United Kingdom & Kensal Green Cemetery \\\\\n", - "\\textbf{5629} & London-Corbin Airport-MaGee Field & London & United States & Alexandra Palace \\\\\n", - "\\textbf{8588} & Le Bourget & Paris & France & Aux Merveilleux de Fred \\\\\n", - "\\bottomrule\n", - "\\end{tabular}\n", - "\n" - ] - } - ], - "source": [ - "result = cluster.query(\n", - " \"\"\"\n", - " SELECT airport.airportname, airport.city, airport.country, landmark.name\n", - " FROM `travel-sample`.inventory.airport airport INNER JOIN `travel-sample`.inventory.landmark landmark on airport.city = landmark.city\n", - " \"\"\",\n", - " QueryOptions(metrics=True),\n", - ")\n", - "print(pd.DataFrame(result).sample(5).sort_index().to_latex(bold_rows=True))" - ] - }, - { - "cell_type": "markdown", - "source": [ - "# End here\n", - "\n", - "This should not be shownm" - ], - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid syntax (2007221166.py, line 3)", - "output_type": "error", - "traceback": [ - "\u001B[1;36m File \u001B[1;32m\"C:\\Users\\phhor\\AppData\\Local\\Temp\\ipykernel_2708\\2007221166.py\"\u001B[1;36m, line \u001B[1;32m3\u001B[0m\n\u001B[1;33m This should not be shownm\u001B[0m\n\u001B[1;37m ^\u001B[0m\n\u001B[1;31mSyntaxError\u001B[0m\u001B[1;31m:\u001B[0m invalid syntax\n" - ] - } - ], - "execution_count": 1 - } - ], - "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.10.8" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -}