Module KhipuDB
source code
KhipuDB is the main interface to the database of khipus.
It contains code to query the database for various khipu properties, as well
as some code to interpret the information in the database or make it easier
to use. For examples, see Khipu.sorted_cords and Cord.numerical.
A simple example of the use of KhipuDB:
import KhipuDB
db = KhipuDB.KhipuDB () ## loads 'khipu.db' from wherever KhipuDB.py lives
db = KhipuDB.KhipuDB ('your_db')
## not for faint of heart: db.execute ('...arbitrary SQL command...')
khipu = db.khipu_with_investigator_num ('UR001')
print khipu.description () ## ASCII description of most text fields
print [cord.cord_length for cord in khipu.cords ()]
cord = khipu.cords () [11] ## some random cord
print cord.short_string () ## 'S1 L9'
print cord.numerical () ## True
print cord.numerify () ## 19
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main()
Prints out the Urton-style description string for the khipu with the
investigator number given on the command line. |
source code
|
|
|
|
preferred_db = ['sqlite', 'mysql']
This allows the user to specify whether they prefer to use the sqlite or
mysql interface to the database.
|
|
|
archive_dc = DescriptionTable('archive_dc', 'archive_num', 'ar...
|
|
|
beginning_dc = DescriptionTable('beginning_dc', 'beg_cd', 'beg...
|
|
|
termination_dc = <KhipuDB.DescriptionTable instance at 0x409d5...
|
|
|
fiber_dc = DescriptionTable('fiber_dc', 'fiber_cd', 'fiber_des...
|
|
|
numerical_re = '^(S. )*(S.|L.|E)?$'
|
|
|
numerical_rec = re.compile(r'^(S. )*(S.|L.|E)?$')
|
|
|
url_map = {<class KhipuDB.Khipu at 0x409d80ec>: ('khipus.html'...
|
|
|
dbmode = 'sqlite'
|
preferred_db
This allows the user to specify whether they prefer to use the sqlite or
mysql interface to the database.
Sqlite is local, but poorly indexed. MySQL queries can run faster due
to better indexing, but the network imposes latency on each request.
- Value:
-
|
archive_dc
- Value:
DescriptionTable('archive_dc', 'archive_num', 'archive_name')
|
|
beginning_dc
- Value:
DescriptionTable('beginning_dc', 'beg_cd', 'beginning_descr')
|
|
termination_dc
- Value:
DescriptionTable('termination_dc', 'term_cd', 'termination_descr')
|
|
fiber_dc
- Value:
DescriptionTable('fiber_dc', 'fiber_cd', 'fiber_descr')
|
|
url_map
- Value:
{Cord:("cords.html", "cords_by_short_string.html"), Khipu:("khipus.htm
l", "khipus_by_short_string.html"),}
|
|