from sqlalchemy import create_engine
import sys, os
import pandas as pd

constr = 'mysql+pymysql://{user}:{pwd}@{host}'.format(user=os.environ['MYSQL_USERNAME'],
                                                      pwd=os.environ['MYSQL_PASSWORD'],
                                                      host=os.environ['MYSQL_HOST'])
con = create_engine(constr)
users = pd.read_sql("""select * from enwiki.categorylinks limit 1""", con)
---------------------------------------------------------------------------
OperationalError                          Traceback (most recent call last)
/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in _execute_context(self, dialect, constructor, statement, parameters, *args)
   1192                         parameters,
-> 1193                         context)
   1194         except BaseException as e:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/default.py in do_execute(self, cursor, statement, parameters, context)
    507     def do_execute(self, cursor, statement, parameters, context=None):
--> 508         cursor.execute(statement, parameters)
    509 

/srv/paws/lib/python3.6/site-packages/pymysql/cursors.py in execute(self, query, args)
    169 
--> 170         result = self._query(query)
    171         self._executed = query

/srv/paws/lib/python3.6/site-packages/pymysql/cursors.py in _query(self, q)
    327         self._clear_result()
--> 328         conn.query(q)
    329         self._do_get_result()

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in query(self, sql, unbuffered)
    892         self._execute_command(COMMAND.COM_QUERY, sql)
--> 893         self._affected_rows = self._read_query_result(unbuffered=unbuffered)
    894         return self._affected_rows

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in _read_query_result(self, unbuffered)
   1102             result = MySQLResult(self)
-> 1103             result.read()
   1104         self._result = result

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in read(self)
   1395         try:
-> 1396             first_packet = self.connection._read_packet()
   1397 

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in _read_packet(self, packet_type)
   1058         packet = packet_type(buff, self.encoding)
-> 1059         packet.check_error()
   1060         return packet

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in check_error(self)
    383             if DEBUG: print("errno =", errno)
--> 384             err.raise_mysql_exception(self._data)
    385 

/srv/paws/lib/python3.6/site-packages/pymysql/err.py in raise_mysql_exception(data)
    108     errorclass = error_map.get(errno, InternalError)
--> 109     raise errorclass(errno, errval)

OperationalError: (1142, "SELECT command denied to user 's52771'@'10.64.37.14' for table 'categorylinks'")

The above exception was the direct cause of the following exception:

OperationalError                          Traceback (most recent call last)
<ipython-input-14-8a4ff461e5e0> in <module>()
----> 1 users = pd.read_sql("""select * from enwiki.categorylinks limit 1""", con)

/srv/paws/lib/python3.6/site-packages/pandas/io/sql.py in read_sql(sql, con, index_col, coerce_float, params, parse_dates, columns, chunksize)
    395             sql, index_col=index_col, params=params,
    396             coerce_float=coerce_float, parse_dates=parse_dates,
--> 397             chunksize=chunksize)
    398 
    399 

/srv/paws/lib/python3.6/site-packages/pandas/io/sql.py in read_query(self, sql, index_col, coerce_float, parse_dates, params, chunksize)
   1061         args = _convert_params(sql, params)
   1062 
-> 1063         result = self.execute(*args)
   1064         columns = result.keys()
   1065 

/srv/paws/lib/python3.6/site-packages/pandas/io/sql.py in execute(self, *args, **kwargs)
    952     def execute(self, *args, **kwargs):
    953         """Simple passthrough to SQLAlchemy connectable"""
--> 954         return self.connectable.execute(*args, **kwargs)
    955 
    956     def read_table(self, table_name, index_col=None, coerce_float=True,

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in execute(self, statement, *multiparams, **params)
   2073 
   2074         connection = self.contextual_connect(close_with_result=True)
-> 2075         return connection.execute(statement, *multiparams, **params)
   2076 
   2077     def scalar(self, statement, *multiparams, **params):

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in execute(self, object, *multiparams, **params)
    940         """
    941         if isinstance(object, util.string_types[0]):
--> 942             return self._execute_text(object, multiparams, params)
    943         try:
    944             meth = object._execute_on_connection

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in _execute_text(self, statement, multiparams, params)
   1102             statement,
   1103             parameters,
-> 1104             statement, parameters
   1105         )
   1106         if self._has_events or self.engine._has_events:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in _execute_context(self, dialect, constructor, statement, parameters, *args)
   1198                 parameters,
   1199                 cursor,
-> 1200                 context)
   1201 
   1202         if self._has_events or self.engine._has_events:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in _handle_dbapi_exception(self, e, statement, parameters, cursor, context)
   1411                 util.raise_from_cause(
   1412                     sqlalchemy_exception,
-> 1413                     exc_info
   1414                 )
   1415             else:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/util/compat.py in raise_from_cause(exception, exc_info)
    201     exc_type, exc_value, exc_tb = exc_info
    202     cause = exc_value if exc_value is not exception else None
--> 203     reraise(type(exception), exception, tb=exc_tb, cause=cause)
    204 
    205 if py3k:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/util/compat.py in reraise(tp, value, tb, cause)
    184             value.__cause__ = cause
    185         if value.__traceback__ is not tb:
--> 186             raise value.with_traceback(tb)
    187         raise value
    188 

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in _execute_context(self, dialect, constructor, statement, parameters, *args)
   1191                         statement,
   1192                         parameters,
-> 1193                         context)
   1194         except BaseException as e:
   1195             self._handle_dbapi_exception(

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/default.py in do_execute(self, cursor, statement, parameters, context)
    506 
    507     def do_execute(self, cursor, statement, parameters, context=None):
--> 508         cursor.execute(statement, parameters)
    509 
    510     def do_execute_no_params(self, cursor, statement, context=None):

/srv/paws/lib/python3.6/site-packages/pymysql/cursors.py in execute(self, query, args)
    168         query = self.mogrify(query, args)
    169 
--> 170         result = self._query(query)
    171         self._executed = query
    172         return result

/srv/paws/lib/python3.6/site-packages/pymysql/cursors.py in _query(self, q)
    326         self._last_executed = q
    327         self._clear_result()
--> 328         conn.query(q)
    329         self._do_get_result()
    330         return self.rowcount

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in query(self, sql, unbuffered)
    891                 sql = sql.encode(self.encoding, 'surrogateescape')
    892         self._execute_command(COMMAND.COM_QUERY, sql)
--> 893         self._affected_rows = self._read_query_result(unbuffered=unbuffered)
    894         return self._affected_rows
    895 

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in _read_query_result(self, unbuffered)
   1101         else:
   1102             result = MySQLResult(self)
-> 1103             result.read()
   1104         self._result = result
   1105         if result.server_status is not None:

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in read(self)
   1394     def read(self):
   1395         try:
-> 1396             first_packet = self.connection._read_packet()
   1397 
   1398             if first_packet.is_ok_packet():

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in _read_packet(self, packet_type)
   1057 
   1058         packet = packet_type(buff, self.encoding)
-> 1059         packet.check_error()
   1060         return packet
   1061 

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in check_error(self)
    382             errno = self.read_uint16()
    383             if DEBUG: print("errno =", errno)
--> 384             err.raise_mysql_exception(self._data)
    385 
    386     def dump(self):

/srv/paws/lib/python3.6/site-packages/pymysql/err.py in raise_mysql_exception(data)
    107         errval = data[3:].decode('utf-8', 'replace')
    108     errorclass = error_map.get(errno, InternalError)
--> 109     raise errorclass(errno, errval)

OperationalError: (pymysql.err.OperationalError) (1142, "SELECT command denied to user 's52771'@'10.64.37.14' for table 'categorylinks'") [SQL: 'select * from enwiki.categorylinks limit 1'] (Background on this error at: http://sqlalche.me/e/e3q8)
os.environ
environ({'PATH': '/srv/paws/pwb:/srv/paws/bin:/srv/paws:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOSTNAME': 'jupyter--50yalex', 'EMAIL': 'Pyalex@local', 'GIT_COMMITTER_NAME': 'Pyalex', 'CLIENT_SECRET': '99b284730a79dd30e2c35988be42708ef7e57122', 'MYSQL_HOST': '10.97.130.38', 'MYSQL_USERNAME': 'Pyalex', 'JUPYTERHUB_OAUTH_CALLBACK_URL': '/paws/user/Pyalex/oauth_callback', 'JUPYTERHUB_API_URL': 'http://10.110.164.126:8081/paws/hub/api', 'ACCESS_KEY': '734774cfec939b580fdff85b055ca2e3', 'USER': 'Pyalex', 'JPY_API_TOKEN': 'c69f65aab2d64b159386d9f89850e258', 'JUPYTERHUB_BASE_URL': '/paws/', 'JUPYTERHUB_SERVICE_PREFIX': '/paws/user/Pyalex/', 'JUPYTERHUB_ADMIN_ACCESS': '1', 'JUPYTERHUB_HOST': '', 'MEM_GUARANTEE': '1073741824', 'GIT_AUTHOR_NAME': 'Pyalex', 'ACCESS_SECRET': '0409f864cd12a31a3a2cabdab680fab79f152396', 'CLIENT_ID': '0a73e346a40b07262b6e36bdba01cba4', 'MYSQL_PASSWORD': 'a0f6d8a0d60c3d91ade14d038b8635800dd5689f6380c043af7b08b2ccbf7560', 'JUPYTERHUB_API_TOKEN': 'c69f65aab2d64b159386d9f89850e258', 'JUPYTERHUB_CLIENT_ID': 'jupyterhub-user-Pyalex', 'JUPYTERHUB_USER': 'Pyalex', 'PROXY_HTTP_PORT_8000_TCP_PROTO': 'tcp', 'HUB_SERVICE_PORT': '8081', 'MYSQL_SERVICE_PORT': '3306', 'PROXY_API_PORT_8001_TCP_ADDR': '10.102.227.179', 'PROXY_PUBLIC_PORT_80_TCP_PORT': '80', 'KUBERNETES_SERVICE_HOST': '10.96.0.1', 'PROXY_PUBLIC_PORT_80_TCP_PROTO': 'tcp', 'KUBERNETES_SERVICE_PORT': '443', 'DEPLOY_HOOK_PORT_8888_TCP_PROTO': 'tcp', 'PROXY_API_PORT_8001_TCP_PROTO': 'tcp', 'HUB_PORT_8081_TCP_PORT': '8081', 'PROXY_PUBLIC_SERVICE_HOST': '10.104.118.81', 'DEPLOY_HOOK_SERVICE_HOST': '10.106.22.165', 'DEPLOY_HOOK_PORT_8888_TCP_ADDR': '10.106.22.165', 'MYSQL_PORT_3306_TCP': 'tcp://10.97.130.38:3306', 'MYSQL_PORT_3306_TCP_ADDR': '10.97.130.38', 'PROXY_PUBLIC_PORT_443_TCP_PORT': '443', 'KUBERNETES_PORT_443_TCP': 'tcp://10.96.0.1:443', 'PROXY_API_SERVICE_HOST': '10.102.227.179', 'PROXY_PUBLIC_PORT_80_TCP_ADDR': '10.104.118.81', 'PROXY_PUBLIC_PORT_443_TCP_ADDR': '10.104.118.81', 'KUBERNETES_SERVICE_PORT_HTTPS': '443', 'DEPLOY_HOOK_PORT_8888_TCP': 'tcp://10.106.22.165:8888', 'DEPLOY_HOOK_PORT_8888_TCP_PORT': '8888', 'DEPLOY_HOOK_SERVICE_PORT': '8888', 'MYSQL_SERVICE_HOST': '10.97.130.38', 'MYSQL_PORT': 'tcp://10.97.130.38:3306', 'MYSQL_PORT_3306_TCP_PROTO': 'tcp', 'PROXY_PUBLIC_SERVICE_PORT_HTTPS': '443', 'PROXY_PUBLIC_PORT_443_TCP': 'tcp://10.104.118.81:443', 'PROXY_HTTP_PORT_8000_TCP': 'tcp://10.110.41.203:8000', 'HUB_PORT_8081_TCP_ADDR': '10.110.164.126', 'KUBERNETES_PORT_443_TCP_ADDR': '10.96.0.1', 'PROXY_API_PORT_8001_TCP': 'tcp://10.102.227.179:8001', 'PROXY_API_PORT_8001_TCP_PORT': '8001', 'PROXY_HTTP_SERVICE_HOST': '10.110.41.203', 'HUB_SERVICE_HOST': '10.110.164.126', 'KUBERNETES_PORT_443_TCP_PROTO': 'tcp', 'PROXY_HTTP_PORT_8000_TCP_PORT': '8000', 'MYSQL_PORT_3306_TCP_PORT': '3306', 'PROXY_PUBLIC_PORT': 'tcp://10.104.118.81:80', 'PROXY_API_PORT': 'tcp://10.102.227.179:8001', 'PROXY_HTTP_SERVICE_PORT': '8000', 'PROXY_HTTP_PORT': 'tcp://10.110.41.203:8000', 'KUBERNETES_PORT': 'tcp://10.96.0.1:443', 'KUBERNETES_PORT_443_TCP_PORT': '443', 'PROXY_API_SERVICE_PORT': '8001', 'HUB_PORT_8081_TCP': 'tcp://10.110.164.126:8081', 'PROXY_HTTP_PORT_8000_TCP_ADDR': '10.110.41.203', 'PROXY_PUBLIC_PORT_80_TCP': 'tcp://10.104.118.81:80', 'DEPLOY_HOOK_PORT': 'tcp://10.106.22.165:8888', 'HUB_PORT': 'tcp://10.110.164.126:8081', 'PROXY_PUBLIC_SERVICE_PORT': '80', 'PROXY_PUBLIC_SERVICE_PORT_HTTP': '80', 'PROXY_PUBLIC_PORT_443_TCP_PROTO': 'tcp', 'HUB_PORT_8081_TCP_PROTO': 'tcp', 'EDITOR': '/bin/nano', 'PYWIKIBOT2_DIR': '/srv/paws', 'SHELL': '/bin/bash', 'NB_USER': 'tools.paws', 'NB_UID': '52771', 'HOME': '/home/paws', 'LC_ALL': 'en_US.UTF-8', 'LANG': 'en_US.UTF-8', 'LANGUAGE': 'en_US.UTF-8', 'JPY_PARENT_PID': '1', 'TERM': 'xterm-color', 'CLICOLOR': '1', 'PAGER': 'cat', 'GIT_PAGER': 'cat', 'MPLBACKEND': 'module://ipykernel.pylab.backend_inline'})