MCPcopy Create free account
hub / github.com/dbt-labs/ade-bench / get_or_create_function

Function get_or_create_function

scripts_python/profiling_statistics.py:154–182  ·  view source on GitHub ↗
(cursor: sqlite3.Cursor, func_tuple: tuple)

Source from the content-addressed store, hash-verified

152
153
154def get_or_create_function(cursor: sqlite3.Cursor, func_tuple: tuple) -> int:
155 filename, line_number, function_name = func_tuple
156
157 is_builtin = filename == "~"
158 module_name = None
159 if not is_builtin and filename:
160 module_name = Path(filename).stem
161
162 cursor.execute(
163 """
164 SELECT id FROM functions
165 WHERE filename = ? AND line_number = ? AND function_name = ?
166 """,
167 (filename, line_number, function_name),
168 )
169
170 row = cursor.fetchone()
171 if row:
172 return row[0]
173
174 cursor.execute(
175 """
176 INSERT INTO functions (filename, line_number, function_name, module_name, is_builtin)
177 VALUES (?, ?, ?, ?, ?)
178 """,
179 (filename, line_number, function_name, module_name, is_builtin),
180 )
181
182 return cursor.lastrowid
183
184
185def import_cprofile_data(cursor: sqlite3.Cursor, run_id: int, prof_path: Path):

Callers 1

import_cprofile_dataFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected