def _pkt_make_auth(self, username=None, password=None, database=None, seed=None, charset=33, client_flags=0): """Make a MySQL Authentication packet""" try: seed = seed or self.scramble except: raise errors.ProgrammingError('Seed missing') (_username, _password, _database) = self._prepare_auth(username, password, database, client_flags, seed) data = utils.int4store(client_flags) +\ utils.int4store(10 * 1024 * 1024) +\ utils.int1store(charset) +\ '\x00'*23 +\ _username +\ _password +\ _database header = self._pkt_make_header(len(data)) return header + data
def make_auth_ssl(self, charset=33, client_flags=0, max_allowed_packet=1073741824): """Make a SSL authentication packet""" return utils.int4store(client_flags) +\ utils.int4store(max_allowed_packet) +\ utils.int1store(charset) +\ '\x00' * 23
def make_auth(self, seed, username=None, password=None, database=None, charset=33, client_flags=0, max_allowed_packet=1073741824): """Make a MySQL Authentication packet""" if not seed: raise errors.ProgrammingError('Seed missing') auth = self._prepare_auth(username, password, database, client_flags, seed) return utils.int4store(client_flags) +\ utils.int4store(max_allowed_packet) +\ utils.int1store(charset) +\ '\x00' * 23 + auth[0] + auth[1] + auth[2]
def _pkt_make_auth_ssl(self, username=None, password=None, database=None, seed=None, charset=33, client_flags=0, max_allowed_packet=None): try: seed = seed or self.scramble except: raise errors.ProgrammingError('Seed missing') if max_allowed_packet is None: max_allowed_packet = 1073741824 # 1Gb (_username, _password, _database) = self._prepare_auth( username, password, database, client_flags, seed) data = utils.int4store(client_flags) +\ utils.int4store(max_allowed_packet) +\ utils.int1store(charset) +\ '\x00'*23 return data
def cmd_process_kill(self, mypid): """Kills a MySQL process using it's ID Returns a dict() with OK-packet information. """ pkt = self._pkt_make_command(ServerCmd.PROCESS_KILL, utils.int4store(mypid)) self.conn.send(pkt) buf = self._recv_packet() return self._handle_ok(buf)
def cmd_process_kill(self, mypid): """Kills a MySQL process using it's ID Returns a dict() with OK-packet information. """ pkt = self._pkt_make_command(ServerCmd.PROCESS_KILL, utils.int4store(mypid)) self.conn.send(pkt,self.next_pktnr) buf = self.conn.recv() return self._handle_ok(buf)
def _pkt_make_auth(self, username=None, password=None, database=None, seed=None, charset=33, client_flags=0): """Make a MySQL Authentication packet""" try: seed = seed or self.scramble except: raise errors.ProgrammingError('Seed missing') (_username, _password, _database) = self._prepare_auth( username, password, database, client_flags, seed) data = utils.int4store(client_flags) +\ utils.int4store(10 * 1024 * 1024) +\ utils.int1store(charset) +\ '\x00'*23 +\ _username +\ _password +\ _database header = self._pkt_make_header(len(data)) return header+data
def cmd_process_kill(self, mysql_pid): """Kill a MySQL process This method send the PROCESS_KILL command to the server along with the process ID. The result is a dictionary with the OK packet information. Returns a dict() """ return self._handle_ok( self._send_cmd(ServerCmd.PROCESS_KILL, int4store(mysql_pid)))
def cmd_refresh(self, options): """Send the Refresh command to the MySQL server This method sends the Refresh command to the MySQL server. The options argument should be a bitwise value using contants.RefreshOption. Usage example: RefreshOption = mysql.connector.RefreshOption refresh = RefreshOption.LOG | RefreshOption.THREADS cnx.cmd_refresh(refresh) The result is a dictionary with the OK packat information. Returns a dict() """ return self._handle_ok( self._send_cmd(ServerCmd.REFRESH, int4store(options)))
def add_4_int(self, i): self.add(utils.int4store(i))