MCPcopy Index your code
hub / github.com/dbcli/mycli / from_version_string

Method from_version_string

mycli/sqlexecute.py:58–79  ·  view source on GitHub ↗
(cls, version_string: str)

Source from the content-addressed store, hash-verified

56
57 @classmethod
58 def from_version_string(cls, version_string: str) -> ServerInfo:
59 if not version_string:
60 return cls(ServerSpecies.MySQL, "")
61
62 re_species = (
63 (r"(?P<version>[0-9\.]+)-MariaDB", ServerSpecies.MariaDB),
64 (r"[0-9\.]*-TiDB-v(?P<version>[0-9\.]+)-?(?P<comment>[a-z0-9\-]*)", ServerSpecies.TiDB),
65 (r"(?P<version>[0-9\.]+)[a-z0-9]*-(?P<comment>[0-9]+$)", ServerSpecies.Percona),
66 # Also matches plain "X.Y.Z" with no suffix (e.g. Homebrew MySQL).
67 (r"(?P<version>[0-9]+\.[0-9]+\.[0-9]+)[a-z0-9]*(-(?P<comment>[A-Za-z0-9_]+))?", ServerSpecies.MySQL),
68 )
69 for regexp, species in re_species:
70 match = re.search(regexp, version_string)
71 if match is not None:
72 parsed_version = match.group("version")
73 detected_species = species
74 break
75 else:
76 detected_species = ServerSpecies.MySQL
77 parsed_version = ""
78
79 return cls(detected_species, parsed_version)
80
81 def __str__(self) -> str:
82 if self.species:

Callers 6

connectMethod · 0.80
test_version_parsingFunction · 0.80
TestExecuteClass · 0.80

Calls

no outgoing calls