How to use the aiomysql.OperationalError function in aiomysql

To help you get started, we’ve selected a few aiomysql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aio-libs / aiomysql / tests / View on Github external
def test_issue_35(self):
        conn = self.connections[0]
        c = yield from conn.cursor()
        print("sudo killall -9 mysqld within the next 10 seconds")
            yield from c.execute("select sleep(10)")
        except aiomysql.OperationalError as e:
            self.assertEqual(2013, e.args[0])
github aio-libs / aiomysql / tests / View on Github external
def test_connect_timeout(self):
        # All exceptions are caught and raised as operational errors
        with self.assertRaises(aiomysql.OperationalError):
            yield from self.connect(connect_timeout=0.000000000001)
github aio-libs / aiomysql / tests / View on Github external
def test_connection_gone_away(self):
        # test
        # error_cr_server_gone_error
        conn = yield from self.connect()
        cur = yield from conn.cursor()
        yield from cur.execute("SET wait_timeout=1")
        yield from asyncio.sleep(2, loop=self.loop)
        with self.assertRaises(aiomysql.OperationalError) as cm:
            yield from cur.execute("SELECT 1+1")
        # error occures while reading, not writing because of socket buffer.
        # self.assertEqual(cm.exception.args[0], 2006)
        self.assertIn(cm.exception.args[0], (2006, 2013))
github mailgyc / doudizhu / doudizhu / contrib / db / View on Github external
async def _execute(self, cursor: aiomysql.Cursor, query: str, args, kwargs):
            return await cursor.execute(query, kwargs or args)
        except aiomysql.OperationalError:
            logging.exception("Error connecting to MySQL on %s", self._db_args['host'])
            await self.close()
github jettify / aiomysql_replication / aiomysql_replication / View on Github external
def fetchone(self):
        while True:

                pkt = yield from self._stream_connection._read_packet()
            except aiomysql.OperationalError as error:
                code, message = error.args
                if code in MYSQL_EXPECTED_ERROR_CODES:
                    self._connected_stream = False

            if pkt.is_eof_packet():
                return None

            if not pkt.is_ok_packet():

            binlog_event = BinLogPacketWrapper(pkt, self.table_map,