select_one: IndexError: tuple index out of range
and-semakin opened this issue · comments
Andrey Semakin commented
Is there a reason why Connection.select_one()
takes second row, and not first from result?
I tried to write a ConnectionFactory that will warn me if I use unencrypted MySQL connection but it fails:
class EncryptionPreferredConnectionFactory(ConnectionFactory):
def _create_connection(
self, driver, connection, database, prefix="", config=None
):
connection = super()._create_connection(
driver, connection, database, prefix, config
)
ssl_cipher = connection.select_one("SHOW STATUS LIKE 'Ssl_cipher';")
if not ssl_cipher["Value"]:
logging.warning("Use of unencrypted connection")
return connection
def select_one(self, query, bindings=None):
if bindings is None:
bindings = {}
records = self.select(query, bindings)
if len(records):
> return records[1]
E IndexError: tuple index out of range