From d05935ea2a9eb870c8d12218da3cb8b03ab05582 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 20 Jul 2013 15:14:03 +0530 Subject: [PATCH] Minor fixes --- src/calibre/debug.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/calibre/debug.py b/src/calibre/debug.py index 090e1d6ced..906fe2f3c4 100644 --- a/src/calibre/debug.py +++ b/src/calibre/debug.py @@ -94,21 +94,21 @@ def reinit_db_new(dbpath, callback=None, sql_dump=None): callback = lambda x, y: None with closing(Connection(dbpath)) as conn: - uv = conn.get('PRAGMA user_version;', all=False) + uv = int(conn.get('PRAGMA user_version;', all=False)) if sql_dump is None: buf = StringIO() shell = apsw.Shell(db=conn, stdout=buf) shell.process_command('.dump') - sql = buf.getvalue().encode('utf-8') + sql = buf.getvalue() else: - sql = open(sql_dump, 'rb').read() + sql = open(sql_dump, 'rb').read().decode('utf-8') dest = dbpath + '.tmp' callback(1, True) try: with closing(Connection(dest)) as conn: conn.execute(sql) - conn.execute('PRAGMA User_version=%d;'%int(uv)) + conn.execute('PRAGMA user_version=%d;'%int(uv)) os.remove(dbpath) shutil.copyfile(dest, dbpath) finally: