mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Improve validating database before import
This commit is contained in:
parent
15a638b86e
commit
a869859491
1 changed files with 9 additions and 2 deletions
|
@ -39,10 +39,17 @@ db_lock = threading.Lock()
|
|||
def validate_database(database=None):
|
||||
try:
|
||||
connection = sqlite3.connect(database, timeout=20)
|
||||
except sqlite3.OperationalError as e:
|
||||
except (sqlite3.OperationalError, sqlite3.DatabaseError, ValueError) as e:
|
||||
logger.error("Tautulli Database :: Invalid database specified: %s", e)
|
||||
return 'Invalid database specified'
|
||||
except ValueError as e:
|
||||
except Exception as e:
|
||||
logger.error("Tautulli Database :: Uncaught exception: %s", e)
|
||||
return 'Uncaught exception'
|
||||
|
||||
try:
|
||||
connection.execute('SELECT started from session_history')
|
||||
connection.close()
|
||||
except (sqlite3.OperationalError, sqlite3.DatabaseError, ValueError) as e:
|
||||
logger.error("Tautulli Database :: Invalid database specified: %s", e)
|
||||
return 'Invalid database specified'
|
||||
except Exception as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue