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)
|
||||
|
||||
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):
|
||||
return map(lambda row: map(value_from_db, row),
|
||||
|
|
|
@ -235,7 +235,7 @@ def list_books(connection):
|
|||
#print fetchall_dict(c)
|
||||
for i in xrange(c.rowcount):
|
||||
book = fetchone_dict(c)
|
||||
write('%-13s %-10s %-60s %s' %
|
||||
write('%-13s %-10s %-60s %s\n' %
|
||||
(book['isbn'], str_or_empty(book['id']),
|
||||
cut_str(book['title'], 60), book['persons']))
|
||||
|
||||
|
@ -244,7 +244,7 @@ def list_persons(connection):
|
|||
c.execute(q_list_persons)
|
||||
for i in xrange(c.rowcount):
|
||||
person = fetchone_dict(c)
|
||||
write('%-5s %-30s %d books' % (person['id'],
|
||||
write('%-5s %-30s %d books\n' % (person['id'],
|
||||
person['firstname']+' '+person['lastname'],
|
||||
person['num_books']))
|
||||
|
||||
|
@ -253,7 +253,7 @@ def list_categories(connection):
|
|||
c.execute(q_list_categories)
|
||||
for i in xrange(c.rowcount):
|
||||
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):
|
||||
funs = { 'book': list_books,
|
||||
|
|
Reference in New Issue