some small bugfixes
This commit is contained in:
parent
9a733ef73a
commit
39361112bc
|
@ -18,7 +18,10 @@ def execute_query(cursor, query, bindings):
|
||||||
cursor.execute(query, bindings)
|
cursor.execute(query, bindings)
|
||||||
|
|
||||||
def fetchone(cursor):
|
def fetchone(cursor):
|
||||||
return map(value_from_db, cursor.fetchone())
|
a = cursor.fetchone()
|
||||||
|
if a != None:
|
||||||
|
return map(value_from_db, a)
|
||||||
|
return None
|
||||||
|
|
||||||
def fetchall(cursor):
|
def fetchall(cursor):
|
||||||
return map(lambda row: map(value_from_db, row),
|
return map(lambda row: map(value_from_db, row),
|
||||||
|
|
|
@ -235,7 +235,7 @@ def list_books(connection):
|
||||||
#print fetchall_dict(c)
|
#print fetchall_dict(c)
|
||||||
for i in xrange(c.rowcount):
|
for i in xrange(c.rowcount):
|
||||||
book = fetchone_dict(c)
|
book = fetchone_dict(c)
|
||||||
write('%-13s %-10s %-60s %s' %
|
write('%-13s %-10s %-60s %s\n' %
|
||||||
(book['isbn'], str_or_empty(book['id']),
|
(book['isbn'], str_or_empty(book['id']),
|
||||||
cut_str(book['title'], 60), book['persons']))
|
cut_str(book['title'], 60), book['persons']))
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ def list_persons(connection):
|
||||||
c.execute(q_list_persons)
|
c.execute(q_list_persons)
|
||||||
for i in xrange(c.rowcount):
|
for i in xrange(c.rowcount):
|
||||||
person = fetchone_dict(c)
|
person = fetchone_dict(c)
|
||||||
write('%-5s %-30s %d books' % (person['id'],
|
write('%-5s %-30s %d books\n' % (person['id'],
|
||||||
person['firstname']+' '+person['lastname'],
|
person['firstname']+' '+person['lastname'],
|
||||||
person['num_books']))
|
person['num_books']))
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ def list_categories(connection):
|
||||||
c.execute(q_list_categories)
|
c.execute(q_list_categories)
|
||||||
for i in xrange(c.rowcount):
|
for i in xrange(c.rowcount):
|
||||||
cat = fetchone_dict(c)
|
cat = fetchone_dict(c)
|
||||||
write('%-15s %-30s %d books' % (cat['id'], cat['name'], cat['num_books']))
|
write('%-15s %-30s %d books\n' % (cat['id'], cat['name'], cat['num_books']))
|
||||||
|
|
||||||
def list_cmd(connection, what):
|
def list_cmd(connection, what):
|
||||||
funs = { 'book': list_books,
|
funs = { 'book': list_books,
|
||||||
|
|
Reference in New Issue