MCPcopy
hub / github.com/PyMySQL/PyMySQL / raise_mysql_exception

Function raise_mysql_exception

pymysql/err.py:141–154  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

139
140
141def raise_mysql_exception(data):
142 errno = struct.unpack("<h", data[1:3])[0]
143 # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html
144 # Error packet has optional sqlstate that is 5 bytes and starts with '#'.
145 sqlstate = None
146 if data[3] == 0x23: # '#'
147 sqlstate = data[4:9].decode()
148 errval = data[9:].decode("utf-8", "replace")
149 else:
150 errval = data[3:].decode("utf-8", "replace")
151 errorclass = error_map.get(errno)
152 if errorclass is None:
153 errorclass = InternalError if errno < 1000 else OperationalError
154 raise errorclass(errno, errval, sqlstate=sqlstate)

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…