source:
vendor/python/2.5/Doc/lib/sqlite3/collation_reverse.py
| Last change on this file was 3225, checked in by , 19 years ago | |
|---|---|
| File size: 400 bytes | |
| Line | |
|---|---|
| 1 | import sqlite3 |
| 2 | |
| 3 | def collate_reverse(string1, string2): |
| 4 | return -cmp(string1, string2) |
| 5 | |
| 6 | con = sqlite3.connect(":memory:") |
| 7 | con.create_collation("reverse", collate_reverse) |
| 8 | |
| 9 | cur = con.cursor() |
| 10 | cur.execute("create table test(x)") |
| 11 | cur.executemany("insert into test(x) values (?)", [("a",), ("b",)]) |
| 12 | cur.execute("select x from test order by x collate reverse") |
| 13 | for row in cur: |
| 14 | print row |
| 15 | con.close() |
Note:
See TracBrowser
for help on using the repository browser.
