MCPcopy Index your code
hub / github.com/PyMySQL/PyMySQL / test_issue_17

Method test_issue_17

pymysql/tests/test_issues.py:150–175  ·  view source on GitHub ↗

could not connect mysql use password

(self)

Source from the content-addressed store, hash-verified

148 "test_issue_17() requires a custom, legacy MySQL configuration and will not be run."
149 )
150 def test_issue_17(self):
151 """could not connect mysql use password"""
152 conn = self.connect()
153 host = self.databases[0]["host"]
154 db = self.databases[0]["database"]
155 c = conn.cursor()
156
157 # grant access to a table to a user with a password
158 try:
159 with warnings.catch_warnings():
160 warnings.filterwarnings("ignore")
161 c.execute("drop table if exists issue17")
162 c.execute("create table issue17 (x varchar(32) primary key)")
163 c.execute("insert into issue17 (x) values ('hello, world!')")
164 c.execute(
165 "grant all privileges on %s.issue17 to 'issue17user'@'%%' identified by '1234'"
166 % db
167 )
168 conn.commit()
169
170 conn2 = pymysql.connect(host=host, user="issue17user", passwd="1234", db=db)
171 c2 = conn2.cursor()
172 c2.execute("select x from issue17")
173 self.assertEqual("hello, world!", c2.fetchone()[0])
174 finally:
175 c.execute("drop table issue17")
176
177
178class TestNewIssues(base.PyMySQLTestCase):

Callers

nothing calls this directly

Calls 5

cursorMethod · 0.80
executeMethod · 0.80
commitMethod · 0.80
connectMethod · 0.45
fetchoneMethod · 0.45

Tested by

no test coverage detected