Visitar URL original
change_user · Issue #241 · PyMySQL/PyMySQL · GitHub
Skip to content

change_user #241

Description

Would you please add the following API like mysql-python for compatibility?
change_user()
set_character_set()
The sample implementation below for reference

*** connections.py.orig 2014-05-21 11:36:59.176700393 +0900
--- connections.py  2014-05-21 11:36:49.020550346 +0900
***************
*** 968,971 ****
--- 968,1017 ----
              if DEBUG: auth_packet.dump()

+     def _request_change_user(self):
+         if self.user is None:
+             raise ValueError("Dit not specify a username to change")
+ 
+         if isinstance(self.user, text_type):
+             self.user = self.user.encode(self.encoding)
+ 
+         data = int2byte(COM_CHANGE_USER) + self.user + b'\0' + \
+                _scramble(self.password.encode('latin1'), self.salt)
+ 
+         if self.db is not None:
+             if isinstance(self.db, text_type):
+                 self.db = self.db.encode(self.encoding)
+             data += self.db + int2byte(0)
+         else:
+             data += int2byte(0)
+ 
+         data = struct.pack("<i",len(data)) + data
+ 
+         self._write_bytes(data)
+         self._read_query_result()
+ 
+     def change_user(self,user=None,passwd=None,db=None):
+         if user is None:
+             user = self.user
+         if passwd is None:
+             passwd = self.passwd
+         if db is None:
+             db = self.db
+         save_user = self.user
+         save_passwd = self.password
+         save_db = self.db
+         try:
+             self.user = user
+             self.passwd = passwd
+             self.db = db
+             self._request_change_user()
+         except:
+             self.user = save_user
+             self.passwd = save_passwd
+             self.db = save_db
+             raise
+ 
+     def set_character_set(self,charset):
+         self.set_charset(charset)
+ 
      # _mysql support
      def thread_id(self):

Activity

  1. added this to the milestone on Jul 28, 2016
  2. modified the milestones: , on Aug 30, 2016
  3. elemount commented on Aug 10, 2017

    @elemount
    Contributor

    @methane , I want to add the change user API pull request. @methane , or do you already have a plan or some code on it? If so, I'll do nothing to avoid useless work.

  4. removed this from the 0.8 milestone on Jun 27, 2018
  5. gganley commented on Apr 11, 2019

    @gganley

    @methane Myself and a couple of other students are volunteering to help with this project for our senior capstone, looking at this issue and the code base as a whole this looks like a good place for me to start. Would you want the signature to still be

    def change_user(user=None, pw=None,db=None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions