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

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

#countcontent
1n/aimport sqlite3
2n/a
3n/adef collate_reverse(string1, string2):
4n/a if string1 == string2:
5n/a return 0
6n/a elif string1 < string2:
7n/a return 1
8n/a else:
9n/a return -1
10n/a
11n/acon = sqlite3.connect(":memory:")
12n/acon.create_collation("reverse", collate_reverse)
13n/a
14n/acur = con.cursor()
15n/acur.execute("create table test(x)")
16n/acur.executemany("insert into test(x) values (?)", [("a",), ("b",)])
17n/acur.execute("select x from test order by x collate reverse")
18n/afor row in cur:
19n/a print(row)
20n/acon.close()