Projects/worblehat-old
Projects
/
worblehat-old
Archived
12
0
Fork 0

some small bugfixes

This commit is contained in:
Péter Henrik Gombos 2012-11-01 12:12:28 +00:00
parent 9a733ef73a
commit 39361112bc
2 changed files with 7 additions and 4 deletions

View File

@ -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),

View File

@ -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,