Skip to content

Commit

Permalink
Add logging; fix password encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
kesmit13 committed Jan 8, 2024
1 parent 5d42aca commit dd19ccf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion singlestoredb/mysql/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from .. import fusion
from .. import connection
from ..connection import Connection as BaseConnection
from ..utils.debug import log_query

try:
import ssl
Expand Down Expand Up @@ -663,13 +664,15 @@ def _read_ok_packet(self):

def _send_autocommit_mode(self):
"""Set whether or not to commit after every execute()."""
log_query('SET AUTOCOMMIT = %s' % self.escape(self.autocommit_mode))
self._execute_command(
COMMAND.COM_QUERY, 'SET AUTOCOMMIT = %s' % self.escape(self.autocommit_mode),
)
self._read_ok_packet()

def begin(self):
"""Begin transaction."""
log_query('BEGIN')
self._execute_command(COMMAND.COM_QUERY, 'BEGIN')
self._read_ok_packet()

Expand All @@ -681,6 +684,7 @@ def commit(self):
in the specification.
"""
log_query('COMMIT')
self._execute_command(COMMAND.COM_QUERY, 'COMMIT')
self._read_ok_packet()

Expand All @@ -692,11 +696,13 @@ def rollback(self):
in the specification.
"""
log_query('ROLLBACK')
self._execute_command(COMMAND.COM_QUERY, 'ROLLBACK')
self._read_ok_packet()

def show_warnings(self):
"""Send the "SHOW WARNINGS" SQL command."""
log_query('SHOW WARNINGS')
self._execute_command(COMMAND.COM_QUERY, 'SHOW WARNINGS')
result = self.resultclass(self)
result.read()
Expand Down Expand Up @@ -909,7 +915,10 @@ def _sync_connection(self):
self.host = out['host']
self.port = out['port']
self.user = out['user']
self.password = out['password']
if isinstance(out['password'], str):
self.password = out['password'].encode('latin-1')
else:
self.password = out['password'] or b''
self.db = out.get('database')
try:
self._in_sync = True
Expand Down

0 comments on commit dd19ccf

Please sign in to comment.