ยปCore Development>Code coverage>Doc/includes/sqlite3/complete_statement.py

Python code coverage for Doc/includes/sqlite3/complete_statement.py

#countcontent
1n/a# A minimal SQLite shell for experiments
2n/a
3n/aimport sqlite3
4n/a
5n/acon = sqlite3.connect(":memory:")
6n/acon.isolation_level = None
7n/acur = con.cursor()
8n/a
9n/abuffer = ""
10n/a
11n/aprint("Enter your SQL commands to execute in sqlite3.")
12n/aprint("Enter a blank line to exit.")
13n/a
14n/awhile True:
15n/a line = input()
16n/a if line == "":
17n/a break
18n/a buffer += line
19n/a if sqlite3.complete_statement(buffer):
20n/a try:
21n/a buffer = buffer.strip()
22n/a cur.execute(buffer)
23n/a
24n/a if buffer.lstrip().upper().startswith("SELECT"):
25n/a print(cur.fetchall())
26n/a except sqlite3.Error as e:
27n/a print("An error occurred:", e.args[0])
28n/a buffer = ""
29n/a
30n/acon.close()