change_user

未关闭
#241 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
30/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
mysql, python
领域
databases

调研方向

Start in connections.py and compare the requested change_user() and set_character_set() APIs with the existing connection methods and the supplied mysql-python sample. Check the compatibility behavior and error handling before deciding how they fit the current API. Done means both requested methods are exposed with the expected mysql-python-compatible behavior.

由索引模型根据 Issue 内容生成。

描述

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):
主要语言
Python
星标
7.8k
派生
1.4k
平均合并
5 小时 40 分钟
30 天内合并 PR
5

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PyMySQL/PyMySQL 的其他 Issue

查看 PyMySQL/PyMySQL 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。