-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathutils.py
More file actions
31 lines (25 loc) · 939 Bytes
/
utils.py
File metadata and controls
31 lines (25 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
TABLEPRAGMA = "PRAGMA table_info(%s);"
def print_table_metadata(cursor):
tmpl = "%-10s |"
rowdata = cursor.description
results = cursor.fetchall()
for col in rowdata:
print tmpl % col[0],
print '\n' + '-----------+-'*len(rowdata)
for row in results:
for value in row:
print tmpl % value,
print '\n' + '-----------+-'*len(rowdata)
print '\n'
def show_table_metadata(cursor, tablename):
stmt = TABLEPRAGMA % tablename
cursor.execute(stmt)
print "Table Metadata for '%s':" % tablename
print_table_metadata(cursor)
AUTHORS_BOOKS = {
'China Mieville': ["Perdido Street Station", "The Scar", "King Rat"],
'Frank Herbert': ["Dune", "Hellstrom's Hive"],
'J.R.R. Tolkien': ["The Hobbit", "The Silmarillion"],
'Susan Cooper': ["The Dark is Rising", ["The Greenwitch"]],
'Madeline L\'Engle': ["A Wrinkle in Time", "A Swiftly Tilting Planet"]
}