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

Method mysql_server_is

pymysql/tests/base.py:30–49  ·  view source on GitHub ↗

Return True if the given connection is on the version given or greater. This only checks the server version string provided when the connection is established, therefore any check for a version tuple greater than (5, 5, 5) will always fail on MariaDB, as it always

(self, conn, version_tuple)

Source from the content-addressed store, hash-verified

28 ]
29
30 def mysql_server_is(self, conn, version_tuple):
31 """Return True if the given connection is on the version given or
32 greater.
33
34 This only checks the server version string provided when the
35 connection is established, therefore any check for a version tuple
36 greater than (5, 5, 5) will always fail on MariaDB, as it always
37 starts with 5.5.5, e.g. 5.5.5-10.7.1-MariaDB-1:10.7.1+maria~focal.
38
39 e.g.::
40
41 if self.mysql_server_is(conn, (5, 6, 4)):
42 # do something for MySQL 5.6.4 and above
43 """
44 server_version = conn.get_server_info()
45 server_version_tuple = tuple(
46 (int(dig) if dig is not None else 0)
47 for dig in re.match(r"(\d+)\.(\d+)\.(\d+)", server_version).group(1, 2, 3)
48 )
49 return server_version_tuple >= version_tuple
50
51 def get_mysql_vendor(self, conn):
52 server_version = conn.get_server_info()

Callers 2

test_escape_stringMethod · 0.80
test_jsonMethod · 0.80

Calls 1

get_server_infoMethod · 0.80

Tested by 2

test_escape_stringMethod · 0.64
test_jsonMethod · 0.64