Example #1
0
# Select all Japanese planes.
print db.select('plane.tbl', ['country'],['Japan'])

# Select all US planes with a speed greater than 400mph.  When specifiying
# selection criteria against numeric fields, you use python comparison
# expressions (i.e. >,<,==,>=,<=).
print db.select('plane.tbl', ['country','speed'],['USA','>400'])

# Select all bombers, but not fighter-bombers.  When specifying selection
# criteria against string fields, you use python regular expression syntax.
print db.select('plane.tbl', ['role'],['^Bomber'])

# Select all planes, sorted by speed in descending order (i.e. fastest first).
# Include only name and speed in the result set.
print db.select('plane.tbl', ['name'],['.*'],['name','speed'],
 sortField='speed',ascending=False)

# Select all planes that entered service before January 1st, 1942, sorted
# by the date they began service.
print db.select('plane.tbl', ['began_service'],
 ['<%s' % datetime.date(1942,1,1)], sortField='began_service')

# Select all planes that are still flying.
print db.select('plane.tbl', ['still_flying'],[True])

# Select all planes.
print db.select('plane.tbl', ['recno'], ['*'])

# Get total number of records in plane table.
print 'Total records: ', db.len('plane.tbl')