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

Class SQLExecute

mycli/sqlexecute.py:88–637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86
87
88class SQLExecute:
89 databases_query = """SHOW DATABASES"""
90
91 tables_query = """SHOW TABLES"""
92
93 show_candidates_query = '''SELECT name from mysql.help_topic WHERE name like "SHOW %"'''
94
95 users_query = """SELECT CONCAT("'", user, "'@'",host,"'") FROM mysql.user"""
96
97 functions_query = '''SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES
98 WHERE ROUTINE_TYPE="FUNCTION" AND ROUTINE_SCHEMA = %s'''
99
100 procedures_query = '''SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES
101 WHERE ROUTINE_TYPE="PROCEDURE" AND ROUTINE_SCHEMA = %s'''
102
103 character_sets_query = '''SHOW CHARACTER SET'''
104
105 collations_query = '''SHOW COLLATION'''
106
107 table_columns_query = """select TABLE_NAME, COLUMN_NAME from information_schema.columns
108 where table_schema = %s
109 order by table_name,ordinal_position"""
110
111 enum_values_query = """select TABLE_NAME, COLUMN_NAME, COLUMN_TYPE from information_schema.columns
112 where table_schema = %s and data_type = 'enum'
113 order by table_name,ordinal_position"""
114
115 foreign_keys_query = """SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
116 FROM information_schema.KEY_COLUMN_USAGE
117 WHERE TABLE_SCHEMA = %s AND REFERENCED_TABLE_NAME IS NOT NULL"""
118
119 now_query = """SELECT NOW()"""
120
121 @staticmethod
122 def _parse_enum_values(column_type: str) -> list[str]:
123 if not column_type or not column_type.lower().startswith("enum("):
124 return []
125
126 values: list[str] = []
127 current: list[str] = []
128 in_quote = False
129 i = column_type.find("(") + 1
130
131 while i < len(column_type):
132 ch = column_type[i]
133
134 if not in_quote:
135 if ch == "'":
136 in_quote = True
137 current = []
138 elif ch == ")":
139 break
140 else:
141 if ch == "\\" and i + 1 < len(column_type):
142 current.append(column_type[i + 1])
143 i += 1
144 elif ch == "'":
145 if i + 1 < len(column_type) and column_type[i + 1] == "'":

Callers 9

_bg_refreshMethod · 0.90
_make_executorMethod · 0.90
_connectMethod · 0.90
test_binary_display_hexFunction · 0.90
test_binary_display_utf8Function · 0.90

Calls

no outgoing calls