From: Oleg Broytman Date: Mon, 30 May 2016 21:32:11 +0000 (+0300) Subject: Open file as an SQLite DB X-Git-Tag: 0.0.10~2 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=1b4e677c375c8d518574c84406428f1ccbcc6022;p=m_librarian.git Open file as an SQLite DB Convert a relative path to an absolute, and an absolute to an SQLite DB URI. --- 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':