From 1b4e677c375c8d518574c84406428f1ccbcc6022 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Tue, 31 May 2016 00:32:11 +0300 Subject: [PATCH] Open file as an SQLite DB Convert a relative path to an absolute, and an absolute to an SQLite DB URI. --- m_librarian/db.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/m_librarian/db.py b/m_librarian/db.py index f65569c..9a48caa 100755 --- a/m_librarian/db.py +++ b/m_librarian/db.py @@ -142,6 +142,14 @@ def open_db(db_uri=None): except: db_uri = find_sqlite_dburi() + if db_uri.startswith(os.sep) or db_uri.startswith(os.altsep) \ + or db_uri.startswith(os.pardir + os.sep) \ + or db_uri.startswith(os.pardir + os.altsep): + if db_uri.startswith(os.pardir + os.sep) \ + or db_uri.startswith(os.pardir + os.altsep): + db_uri = os.path.abspath(db_uri) + db_uri = 'sqlite://' + db_uri.replace(os.sep, '/') + sqlhub.processConnection = connection = connectionForURI(db_uri) if connection.dbName == 'sqlite': -- 2.39.2