diff --git a/pastepwn/database/sqlitedb.py b/pastepwn/database/sqlitedb.py index 178e2bd..ef4861a 100644 --- a/pastepwn/database/sqlitedb.py +++ b/pastepwn/database/sqlitedb.py @@ -15,10 +15,14 @@ def __init__(self, dbpath="pastepwn"): self.logger.debug("Initializing SQLite - {0}".format(dbpath)) # Check if the folder path exists - if not os.path.exists(os.path.dirname(dbpath)): + if not os.path.exists(dbpath): # If not, create the path and the file - os.mkdir(os.path.dirname(dbpath)) + dbdir = os.path.dirname(dbpath) + if dbdir != '': + os.mkdir(dbdir) open(self.dbpath, "a").close() + elif os.path.isdir(dbpath): + raise ValueError('\'{0}\' is a directory. Use different path/name for database.'.format(dbpath)) try: self.db = sqlite3.connect(dbpath, check_same_thread=False)