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