MCPcopy Index your code
hub / github.com/python/cpython / execute

Function execute

Lib/sqlite3/__main__.py:18–41  ·  view source on GitHub ↗

Helper that wraps execution of SQL code. This is used both by the REPL and by direct execution from the CLI. 'c' may be a cursor or a connection. 'sql' is the SQL string to execute.

(c, sql, suppress_errors=True, theme=theme_no_color)

Source from the content-addressed store, hash-verified

16
17
18def execute(c, sql, suppress_errors=True, theme=theme_no_color):
19 """Helper that wraps execution of SQL code.
20
21 This is used both by the REPL and by direct execution from the CLI.
22
23 'c' may be a cursor or a connection.
24 'sql' is the SQL string to execute.
25 """
26
27 try:
28 for row in c.execute(sql):
29 print(row)
30 except sqlite3.Error as e:
31 t = theme.traceback
32 tp = type(e).__name__
33 try:
34 tp += f" ({e.sqlite_errorname})"
35 except AttributeError:
36 pass
37 print(
38 f"{t.type}{tp}{t.reset}: {t.message}{e}{t.reset}", file=sys.stderr
39 )
40 if not suppress_errors:
41 sys.exit(1)
42
43
44class SqliteInteractiveConsole(InteractiveConsole):

Calls 2

executeMethod · 0.45
exitMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…