Skip to content

Instantly share code, notes, and snippets.

@shawnzhu
Created June 15, 2019 02:30
Show Gist options
  • Save shawnzhu/5477769fb746efcc9bbae07e3934a74b to your computer and use it in GitHub Desktop.
Save shawnzhu/5477769fb746efcc9bbae07e3934a74b to your computer and use it in GitHub Desktop.
use ibmcloudsql in jupyter notebook
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting ibmcloudsql\n",
" Downloading https://files.pythonhosted.org/packages/e0/11/fc31cb788441b806e316cd8c77600a5537e532dbc97d7743e758fc0ccb9b/ibmcloudsql-0.2.23.tar.gz\n",
"Requirement already satisfied: pandas in /opt/conda/lib/python3.7/site-packages (0.24.2)\n",
"Requirement already satisfied: urllib3 in /opt/conda/lib/python3.7/site-packages (from ibmcloudsql) (1.24.2)\n",
"Collecting simplejson (from ibmcloudsql)\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/e3/24/c35fb1c1c315fc0fffe61ea00d3f88e85469004713dab488dee4f35b0aff/simplejson-3.16.0.tar.gz (81kB)\n",
"\u001b[K |████████████████████████████████| 81kB 2.6MB/s eta 0:00:011\n",
"\u001b[?25hCollecting tornado<=4.5.2 (from ibmcloudsql)\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/fa/14/52e2072197dd0e63589e875ebf5984c91a027121262aa08f71a49b958359/tornado-4.5.2.tar.gz (483kB)\n",
"\u001b[K |████████████████████████████████| 491kB 5.5MB/s eta 0:00:01\n",
"\u001b[?25hCollecting botocore (from ibmcloudsql)\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/28/ac/a43d37f371f5854514128d7c54887176b8df3bc9925a25e5096298033f93/botocore-1.12.169-py2.py3-none-any.whl (5.5MB)\n",
"\u001b[K |████████████████████████████████| 5.6MB 7.5MB/s eta 0:00:01\n",
"\u001b[?25hCollecting ibm-cos-sdk (from ibmcloudsql)\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/b1/d4/7e1fe33819b80d47dafa5c02c905f7acbbdff7e6cca9af668aaeaa127990/ibm-cos-sdk-2.4.4.tar.gz (50kB)\n",
"\u001b[K |████████████████████████████████| 51kB 10.4MB/s eta 0:00:01\n",
"\u001b[?25hRequirement already satisfied: numpy in /opt/conda/lib/python3.7/site-packages (from ibmcloudsql) (1.15.4)\n",
"Collecting pyarrow (from ibmcloudsql)\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/3f/6c/91a3d949fe0763e60ac181b7b79e74e848e33e402e5e8274cad455519d76/pyarrow-0.13.0-cp37-cp37m-manylinux1_x86_64.whl (48.5MB)\n",
"\u001b[K |████████████████████████████████| 48.5MB 16.9MB/s eta 0:00:01 |█▉ | 2.8MB 22.5MB/s eta 0:00:03 |██████████▉ | 16.5MB 6.1MB/s eta 0:00:06 |█████████████████████▎ | 32.3MB 3.8MB/s eta 0:00:05\n",
"\u001b[?25hRequirement already satisfied: python-dateutil>=2.5.0 in /opt/conda/lib/python3.7/site-packages (from pandas) (2.8.0)\n",
"Requirement already satisfied: pytz>=2011k in /opt/conda/lib/python3.7/site-packages (from pandas) (2019.1)\n",
"Collecting docutils>=0.10 (from botocore->ibmcloudsql)\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/36/fa/08e9e6e0e3cbd1d362c3bbee8d01d0aedb2155c4ac112b19ef3cae8eed8d/docutils-0.14-py3-none-any.whl (543kB)\n",
"\u001b[K |████████████████████████████████| 552kB 11.6MB/s eta 0:00:01\n",
"\u001b[?25hCollecting jmespath<1.0.0,>=0.7.1 (from botocore->ibmcloudsql)\n",
" Downloading https://files.pythonhosted.org/packages/83/94/7179c3832a6d45b266ddb2aac329e101367fbdb11f425f13771d27f225bb/jmespath-0.9.4-py2.py3-none-any.whl\n",
"Collecting ibm-cos-sdk-core==2.*,>=2.0.0 (from ibm-cos-sdk->ibmcloudsql)\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/85/72/99afcdf6b92840d47c8765533ef6093e43059424e3b35dd31049f09c8d7a/ibm-cos-sdk-core-2.4.4.tar.gz (1.1MB)\n",
"\u001b[K |████████████████████████████████| 1.1MB 20.9MB/s eta 0:00:01 |█████████████████████▋ | 727kB 20.9MB/s eta 0:00:01\n",
"\u001b[?25hCollecting ibm-cos-sdk-s3transfer==2.*,>=2.0.0 (from ibm-cos-sdk->ibmcloudsql)\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/27/44/c71a4595d311772953775b3588307ac8dd5a36501b3dfda6324173b963cc/ibm-cos-sdk-s3transfer-2.4.4.tar.gz (214kB)\n",
"\u001b[K |████████████████████████████████| 215kB 9.5MB/s eta 0:00:01\n",
"\u001b[?25hRequirement already satisfied: six>=1.0.0 in /opt/conda/lib/python3.7/site-packages (from pyarrow->ibmcloudsql) (1.12.0)\n",
"Building wheels for collected packages: ibmcloudsql, simplejson, tornado, ibm-cos-sdk, ibm-cos-sdk-core, ibm-cos-sdk-s3transfer\n",
" Building wheel for ibmcloudsql (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25h Stored in directory: /home/jovyan/.cache/pip/wheels/a1/88/59/ccb06d57749039e82270a1c210313cdda2d35520e1f2ca04e0\n",
" Building wheel for simplejson (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25h Stored in directory: /home/jovyan/.cache/pip/wheels/5d/1a/1e/0350bb3df3e74215cd91325344cc86c2c691f5306eb4d22c77\n",
" Building wheel for tornado (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25h Stored in directory: /home/jovyan/.cache/pip/wheels/a5/59/09/79aad6522a5811b546e94d55c1535702dcad35880a09b03471\n",
" Building wheel for ibm-cos-sdk (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25h Stored in directory: /home/jovyan/.cache/pip/wheels/e5/dc/54/f601cc8263513665653fbf124f6989dcbaeb218fcf1a8fd4d1\n",
" Building wheel for ibm-cos-sdk-core (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25h Stored in directory: /home/jovyan/.cache/pip/wheels/43/73/3e/79ee45c864491743309c46837d617c0550e58978659b8f742e\n",
" Building wheel for ibm-cos-sdk-s3transfer (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25h Stored in directory: /home/jovyan/.cache/pip/wheels/45/52/14/5239d330c7bd818043a3c578329f1ecff4f1d09694b4c7aa41\n",
"Successfully built ibmcloudsql simplejson tornado ibm-cos-sdk ibm-cos-sdk-core ibm-cos-sdk-s3transfer\n",
"\u001b[31mERROR: jupyterhub 1.0.0 has requirement tornado>=5.0, but you'll have tornado 4.5.2 which is incompatible.\u001b[0m\n",
"\u001b[31mERROR: distributed 1.28.0 has requirement tornado>=5, but you'll have tornado 4.5.2 which is incompatible.\u001b[0m\n",
"Installing collected packages: simplejson, tornado, docutils, jmespath, botocore, ibm-cos-sdk-core, ibm-cos-sdk-s3transfer, ibm-cos-sdk, pyarrow, ibmcloudsql\n",
" Found existing installation: tornado 6.0.2\n",
" Uninstalling tornado-6.0.2:\n",
" Successfully uninstalled tornado-6.0.2\n",
"Successfully installed botocore-1.12.169 docutils-0.14 ibm-cos-sdk-2.4.4 ibm-cos-sdk-core-2.4.4 ibm-cos-sdk-s3transfer-2.4.4 ibmcloudsql-0.2.23 jmespath-0.9.4 pyarrow-0.13.0 simplejson-3.16.0 tornado-4.5.2\n"
]
}
],
"source": [
"!pip install ibmcloudsql pandas"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"ename": "ImportError",
"evalue": "cannot import name 'TracebackFuture' from 'tornado.concurrent' (/opt/conda/lib/python3.7/site-packages/tornado/concurrent.py)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-4fc28aa5c714>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mibmcloudsql\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/opt/conda/lib/python3.7/site-packages/ibmcloudsql/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0;31m# ------------------------------------------------------------------------------\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 17\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m\u001b[0mSQLQuery\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mSQLQuery\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/opt/conda/lib/python3.7/site-packages/ibmcloudsql/SQLQuery.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 21\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mxml\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0metree\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mElementTree\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mET\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 22\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtornado\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mescape\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mjson_decode\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 23\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtornado\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhttpclient\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mHTTPClient\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mHTTPError\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 24\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtornado\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhttputil\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mHTTPHeaders\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0msys\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/conda/lib/python3.7/site-packages/tornado/httpclient.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 45\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mweakref\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 46\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 47\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtornado\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconcurrent\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mTracebackFuture\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 48\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtornado\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mescape\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mutf8\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnative_str\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 49\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtornado\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mhttputil\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstack_context\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mImportError\u001b[0m: cannot import name 'TracebackFuture' from 'tornado.concurrent' (/opt/conda/lib/python3.7/site-packages/tornado/concurrent.py)"
]
}
],
"source": [
"import ibmcloudsql"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Package Version \r\n",
"---------------------- --------\r\n",
"alembic 1.0.8 \r\n",
"asn1crypto 0.24.0 \r\n",
"async-generator 1.10 \r\n",
"attrs 19.1.0 \r\n",
"backcall 0.1.0 \r\n",
"beautifulsoup4 4.7.1 \r\n",
"bleach 3.1.0 \r\n",
"blinker 1.4 \r\n",
"bokeh 1.0.4 \r\n",
"botocore 1.12.169\r\n",
"certifi 2019.3.9\r\n",
"certipy 0.1.3 \r\n",
"cffi 1.12.3 \r\n",
"chardet 3.0.4 \r\n",
"Click 7.0 \r\n",
"cloudpickle 0.8.1 \r\n",
"conda 4.6.14 \r\n",
"cryptography 2.6.1 \r\n",
"cycler 0.10.0 \r\n",
"Cython 0.29.7 \r\n",
"cytoolz 0.9.0.1 \r\n",
"dask 1.1.5 \r\n",
"decorator 4.4.0 \r\n",
"defusedxml 0.5.0 \r\n",
"dill 0.2.9 \r\n",
"distributed 1.28.0 \r\n",
"docutils 0.14 \r\n",
"entrypoints 0.3 \r\n",
"fastcache 1.1.0 \r\n",
"gmpy2 2.0.8 \r\n",
"h5py 2.9.0 \r\n",
"heapdict 1.0.0 \r\n",
"ibm-cos-sdk 2.4.4 \r\n",
"ibm-cos-sdk-core 2.4.4 \r\n",
"ibm-cos-sdk-s3transfer 2.4.4 \r\n",
"ibmcloudsql 0.2.23 \r\n",
"idna 2.8 \r\n",
"imageio 2.5.0 \r\n",
"ipykernel 5.1.0 \r\n",
"ipython 7.5.0 \r\n",
"ipython-genutils 0.2.0 \r\n",
"ipywidgets 7.4.2 \r\n",
"jedi 0.13.3 \r\n",
"Jinja2 2.10.1 \r\n",
"jmespath 0.9.4 \r\n",
"jsonschema 3.0.1 \r\n",
"jupyter-client 5.2.4 \r\n",
"jupyter-core 4.4.0 \r\n",
"jupyterhub 1.0.0 \r\n",
"jupyterlab 0.35.5 \r\n",
"jupyterlab-server 0.2.0 \r\n",
"kiwisolver 1.1.0 \r\n",
"llvmlite 0.27.1 \r\n",
"locket 0.2.0 \r\n",
"Mako 1.0.7 \r\n",
"MarkupSafe 1.1.1 \r\n",
"matplotlib 3.0.3 \r\n",
"mistune 0.8.4 \r\n",
"mpmath 1.1.0 \r\n",
"msgpack 0.6.1 \r\n",
"nbconvert 5.5.0 \r\n",
"nbformat 4.4.0 \r\n",
"networkx 2.3 \r\n",
"notebook 5.7.8 \r\n",
"numba 0.42.1 \r\n",
"numexpr 2.6.9 \r\n",
"numpy 1.15.4 \r\n",
"oauthlib 3.0.1 \r\n",
"olefile 0.46 \r\n",
"packaging 19.0 \r\n",
"pamela 1.0.0 \r\n",
"pandas 0.24.2 \r\n",
"pandocfilters 1.4.2 \r\n",
"parso 0.4.0 \r\n",
"partd 0.3.9 \r\n",
"patsy 0.5.1 \r\n",
"pexpect 4.7.0 \r\n",
"pickleshare 0.7.5 \r\n",
"Pillow 6.0.0 \r\n",
"pip 19.1 \r\n",
"prometheus-client 0.6.0 \r\n",
"prompt-toolkit 2.0.9 \r\n",
"protobuf 3.7.1 \r\n",
"psutil 5.6.2 \r\n",
"ptyprocess 0.6.0 \r\n",
"pyarrow 0.13.0 \r\n",
"pycosat 0.6.3 \r\n",
"pycparser 2.19 \r\n",
"pycurl 7.43.0.2\r\n",
"Pygments 2.4.0 \r\n",
"PyJWT 1.7.1 \r\n",
"pyOpenSSL 19.0.0 \r\n",
"pyparsing 2.4.0 \r\n",
"pyrsistent 0.15.2 \r\n",
"PySocks 1.6.8 \r\n",
"python-dateutil 2.8.0 \r\n",
"python-editor 1.0.4 \r\n",
"pytz 2019.1 \r\n",
"PyWavelets 1.0.3 \r\n",
"PyYAML 5.1 \r\n",
"pyzmq 18.0.1 \r\n",
"requests 2.21.0 \r\n",
"rpy2 2.9.4 \r\n",
"ruamel-yaml 0.15.71 \r\n",
"scikit-image 0.14.2 \r\n",
"scikit-learn 0.20.3 \r\n",
"scipy 1.2.1 \r\n",
"seaborn 0.9.0 \r\n",
"Send2Trash 1.5.0 \r\n",
"setuptools 41.0.1 \r\n",
"simplejson 3.16.0 \r\n",
"six 1.12.0 \r\n",
"sortedcontainers 2.1.0 \r\n",
"soupsieve 1.9.1 \r\n",
"SQLAlchemy 1.3.3 \r\n",
"statsmodels 0.9.0 \r\n",
"sympy 1.3 \r\n",
"tblib 1.3.2 \r\n",
"terminado 0.8.2 \r\n",
"testpath 0.4.2 \r\n",
"toolz 0.9.0 \r\n",
"tornado 4.5.2 \r\n",
"traitlets 4.3.2 \r\n",
"tzlocal 1.5.1 \r\n",
"urllib3 1.24.2 \r\n",
"vincent 0.4.4 \r\n",
"wcwidth 0.1.7 \r\n",
"webencodings 0.5.1 \r\n",
"wheel 0.33.1 \r\n",
"widgetsnbextension 3.4.2 \r\n",
"xlrd 1.2.0 \r\n",
"zict 0.1.4 \r\n"
]
}
],
"source": [
"!pip list"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment