~malept/ubuntu/lucid/python2.6/dev-dependency-fix

« back to all changes in this revision

Viewing changes to Doc/includes/sqlite3/collation_reverse.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-13 12:51:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090213125100-uufgcb9yeqzujpqw
Tags: upstream-2.6.1
ImportĀ upstreamĀ versionĀ 2.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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()