In [1]:
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)
In [2]:
df = pd.read_sql('select * from enwiki_p.page limit 10', con)
---------------------------------------------------------------------------
InternalError                             Traceback (most recent call last)
/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in _wrap_pool_connect(self, fn, connection)
   2261         try:
-> 2262             return fn()
   2263         except dialect.dbapi.Error as e:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in connect(self)
    362         if not self._use_threadlocal:
--> 363             return _ConnectionFairy._checkout(self)
    364 

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in _checkout(cls, pool, threadconns, fairy)
    759         if not fairy:
--> 760             fairy = _ConnectionRecord.checkout(pool)
    761 

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in checkout(cls, pool)
    491     def checkout(cls, pool):
--> 492         rec = pool._do_get()
    493         try:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/impl.py in _do_get(self)
    138                 with util.safe_reraise():
--> 139                     self._dec_overflow()
    140         else:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py in __exit__(self, type_, value, traceback)
     67             if not self.warn_only:
---> 68                 compat.reraise(exc_type, exc_value, exc_tb)
     69         else:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/util/compat.py in reraise(tp, value, tb, cause)
    128             raise value.with_traceback(tb)
--> 129         raise value
    130 

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/impl.py in _do_get(self)
    135             try:
--> 136                 return self._create_connection()
    137             except:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in _create_connection(self)
    307 
--> 308         return _ConnectionRecord(self)
    309 

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in __init__(self, pool, connect)
    436         if connect:
--> 437             self.__connect(first_connect_check=True)
    438         self.finalize_callback = deque()

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in __connect(self, first_connect_check)
    638             self.starttime = time.time()
--> 639             connection = pool._invoke_creator(self)
    640             pool.logger.debug("Created new connection %r", connection)

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py in connect(connection_record)
    113                             return connection
--> 114                 return dialect.connect(*cargs, **cparams)
    115 

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/default.py in connect(self, *cargs, **cparams)
    452     def connect(self, *cargs, **cparams):
--> 453         return self.dbapi.connect(*cargs, **cparams)
    454 

/srv/paws/lib/python3.6/site-packages/pymysql/__init__.py in Connect(*args, **kwargs)
     93     from .connections import Connection
---> 94     return Connection(*args, **kwargs)
     95 

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in __init__(self, host, user, password, database, port, unix_socket, charset, sql_mode, read_default_file, conv, use_unicode, client_flag, cursorclass, init_command, connect_timeout, ssl, read_default_group, compress, named_pipe, autocommit, db, passwd, local_infile, max_allowed_packet, defer_connect, auth_plugin_map, read_timeout, write_timeout, bind_address, binary_prefix, program_name, server_public_key)
    324         else:
--> 325             self.connect()
    326 

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in connect(self, sock)
    597 
--> 598             self._get_server_information()
    599             self._request_authentication()

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in _get_server_information(self)
    974         i = 0
--> 975         packet = self._read_packet()
    976         data = packet.get_all_data()

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

/srv/paws/lib/python3.6/site-packages/pymysql/protocol.py in check_error(self)
    219             if DEBUG: print("errno =", errno)
--> 220             err.raise_mysql_exception(self._data)
    221 

/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)

InternalError: (1105, '(proxy) all backends are down')

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

InternalError                             Traceback (most recent call last)
<ipython-input-2-6d94cd023890> in <module>
----> 1 df = pd.read_sql('select * from enwiki_p.page limit 10', 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)
   1097         args = _convert_params(sql, params)
   1098 
-> 1099         result = self.execute(*args)
   1100         columns = result.keys()
   1101 

/srv/paws/lib/python3.6/site-packages/pandas/io/sql.py in execute(self, *args, **kwargs)
    988     def execute(self, *args, **kwargs):
    989         """Simple passthrough to SQLAlchemy connectable"""
--> 990         return self.connectable.execute(*args, **kwargs)
    991 
    992     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)
   2163         """
   2164 
-> 2165         connection = self._contextual_connect(close_with_result=True)
   2166         return connection.execute(statement, *multiparams, **params)
   2167 

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in _contextual_connect(self, close_with_result, **kwargs)
   2224         return self._connection_cls(
   2225             self,
-> 2226             self._wrap_pool_connect(self.pool.connect, None),
   2227             close_with_result=close_with_result,
   2228             **kwargs

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in _wrap_pool_connect(self, fn, connection)
   2264             if connection is None:
   2265                 Connection._handle_dbapi_exception_noconnection(
-> 2266                     e, dialect, self
   2267                 )
   2268             else:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in _handle_dbapi_exception_noconnection(cls, e, dialect, engine)
   1534             util.raise_from_cause(newraise, exc_info)
   1535         elif should_wrap:
-> 1536             util.raise_from_cause(sqlalchemy_exception, exc_info)
   1537         else:
   1538             util.reraise(*exc_info)

/srv/paws/lib/python3.6/site-packages/sqlalchemy/util/compat.py in raise_from_cause(exception, exc_info)
    381     exc_type, exc_value, exc_tb = exc_info
    382     cause = exc_value if exc_value is not exception else None
--> 383     reraise(type(exception), exception, tb=exc_tb, cause=cause)
    384 
    385 

/srv/paws/lib/python3.6/site-packages/sqlalchemy/util/compat.py in reraise(tp, value, tb, cause)
    126             value.__cause__ = cause
    127         if value.__traceback__ is not tb:
--> 128             raise value.with_traceback(tb)
    129         raise value
    130 

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/base.py in _wrap_pool_connect(self, fn, connection)
   2260         dialect = self.dialect
   2261         try:
-> 2262             return fn()
   2263         except dialect.dbapi.Error as e:
   2264             if connection is None:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in connect(self)
    361         """
    362         if not self._use_threadlocal:
--> 363             return _ConnectionFairy._checkout(self)
    364 
    365         try:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in _checkout(cls, pool, threadconns, fairy)
    758     def _checkout(cls, pool, threadconns=None, fairy=None):
    759         if not fairy:
--> 760             fairy = _ConnectionRecord.checkout(pool)
    761 
    762             fairy._pool = pool

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in checkout(cls, pool)
    490     @classmethod
    491     def checkout(cls, pool):
--> 492         rec = pool._do_get()
    493         try:
    494             dbapi_connection = rec.get_connection()

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/impl.py in _do_get(self)
    137             except:
    138                 with util.safe_reraise():
--> 139                     self._dec_overflow()
    140         else:
    141             return self._do_get()

/srv/paws/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py in __exit__(self, type_, value, traceback)
     66             self._exc_info = None  # remove potential circular references
     67             if not self.warn_only:
---> 68                 compat.reraise(exc_type, exc_value, exc_tb)
     69         else:
     70             if not compat.py3k and self._exc_info and self._exc_info[1]:

/srv/paws/lib/python3.6/site-packages/sqlalchemy/util/compat.py in reraise(tp, value, tb, cause)
    127         if value.__traceback__ is not tb:
    128             raise value.with_traceback(tb)
--> 129         raise value
    130 
    131     def u(s):

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/impl.py in _do_get(self)
    134         if self._inc_overflow():
    135             try:
--> 136                 return self._create_connection()
    137             except:
    138                 with util.safe_reraise():

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in _create_connection(self)
    306         """Called by subclasses to create a new ConnectionRecord."""
    307 
--> 308         return _ConnectionRecord(self)
    309 
    310     def _invalidate(self, connection, exception=None, _checkin=True):

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in __init__(self, pool, connect)
    435         self.__pool = pool
    436         if connect:
--> 437             self.__connect(first_connect_check=True)
    438         self.finalize_callback = deque()
    439 

/srv/paws/lib/python3.6/site-packages/sqlalchemy/pool/base.py in __connect(self, first_connect_check)
    637         try:
    638             self.starttime = time.time()
--> 639             connection = pool._invoke_creator(self)
    640             pool.logger.debug("Created new connection %r", connection)
    641             self.connection = connection

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py in connect(connection_record)
    112                         if connection is not None:
    113                             return connection
--> 114                 return dialect.connect(*cargs, **cparams)
    115 
    116             creator = pop_kwarg("creator", connect)

/srv/paws/lib/python3.6/site-packages/sqlalchemy/engine/default.py in connect(self, *cargs, **cparams)
    451 
    452     def connect(self, *cargs, **cparams):
--> 453         return self.dbapi.connect(*cargs, **cparams)
    454 
    455     def create_connect_args(self, url):

/srv/paws/lib/python3.6/site-packages/pymysql/__init__.py in Connect(*args, **kwargs)
     92     """
     93     from .connections import Connection
---> 94     return Connection(*args, **kwargs)
     95 
     96 from . import connections as _orig_conn

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in __init__(self, host, user, password, database, port, unix_socket, charset, sql_mode, read_default_file, conv, use_unicode, client_flag, cursorclass, init_command, connect_timeout, ssl, read_default_group, compress, named_pipe, autocommit, db, passwd, local_infile, max_allowed_packet, defer_connect, auth_plugin_map, read_timeout, write_timeout, bind_address, binary_prefix, program_name, server_public_key)
    323             self._sock = None
    324         else:
--> 325             self.connect()
    326 
    327     def _create_ssl_ctx(self, sslp):

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in connect(self, sock)
    596             self._next_seq_id = 0
    597 
--> 598             self._get_server_information()
    599             self._request_authentication()
    600 

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in _get_server_information(self)
    973     def _get_server_information(self):
    974         i = 0
--> 975         packet = self._read_packet()
    976         data = packet.get_all_data()
    977 

/srv/paws/lib/python3.6/site-packages/pymysql/connections.py in _read_packet(self, packet_type)
    682 
    683         packet = packet_type(buff, self.encoding)
--> 684         packet.check_error()
    685         return packet
    686 

/srv/paws/lib/python3.6/site-packages/pymysql/protocol.py in check_error(self)
    218             errno = self.read_uint16()
    219             if DEBUG: print("errno =", errno)
--> 220             err.raise_mysql_exception(self._data)
    221 
    222     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)

InternalError: (pymysql.err.InternalError) (1105, '(proxy) all backends are down')
(Background on this error at: http://sqlalche.me/e/2j85)
In [5]:
df
Out[5]:
page_id page_namespace page_title page_restrictions page_is_redirect page_is_new page_random page_touched page_links_updated page_latest page_len page_content_model page_lang
0 10 0 b'AccessibleComputing' b'' 1 0 0.331671 b'20191003224230' b'20190105021557' 854851586 94 b'wikitext' None
1 12 0 b'Anarchism' b'' 0 0 0.786172 b'20191109030747' b'20191109030901' 925150118 104687 b'wikitext' None
2 13 0 b'AfghanistanHistory' b'' 1 0 0.062150 b'20191029091312' b'20190618192734' 783865149 90 b'wikitext' None
3 14 0 b'AfghanistanGeography' b'' 1 0 0.952234 b'20191016144702' b'20190618192734' 783865160 92 b'wikitext' None
4 15 0 b'AfghanistanPeople' b'' 1 0 0.574721 b'20191104232438' b'20190618192734' 783865293 95 b'wikitext' None
5 18 0 b'AfghanistanCommunications' b'' 1 0 0.751068 b'20190916234018' b'20190618192734' 783865299 97 b'wikitext' None
6 19 0 b'AfghanistanTransportations' b'' 1 0 0.674273 b'20190926165308' b'20190618192735' 783821589 113 b'wikitext' None
7 20 0 b'AfghanistanMilitary' b'' 1 0 0.118158 b'20191015052253' b'20190618192735' 783821738 88 b'wikitext' None
8 21 0 b'AfghanistanTransnationalIssues' b'' 1 0 0.567973 b'20191029174151' b'20190618192735' 783821743 101 b'wikitext' None
9 23 0 b'AssistiveTechnology' b'' 1 0 0.723041 b'20191101053211' b'20190618192735' 783865310 88 b'wikitext' None
In [ ]: