MCPcopy Create free account
hub / github.com/PyMySQL/PyMySQL / __init__

Method __init__

pymysql/tests/test_connection.py:14–35  ·  view source on GitHub ↗
(self, c, user, db, auth=None, authdata=None, password=None)

Source from the content-addressed store, hash-verified

12
13class TempUser:
14 def __init__(self, c, user, db, auth=None, authdata=None, password=None):
15 self._c = c
16 self._user = user
17 self._db = db
18 create = "CREATE USER " + user
19 if password is not None:
20 create += " IDENTIFIED BY '%s'" % password
21 elif auth is not None:
22 create += " IDENTIFIED WITH %s" % auth
23 if authdata is not None:
24 create += " AS '%s'" % authdata
25 try:
26 c.execute(create)
27 self._created = True
28 except pymysql.err.InternalError:
29 # already exists - TODO need to check the same plugin applies
30 self._created = False
31 try:
32 c.execute(f"GRANT SELECT ON {db}.* TO {user}")
33 self._grant = True
34 except pymysql.err.InternalError:
35 self._grant = False
36
37 def __enter__(self):
38 return self

Callers

nothing calls this directly

Calls 1

executeMethod · 0.80

Tested by

no test coverage detected