[2/2] Don't require all Python database modules to be installed

Message ID 20191123173120.11185-2-lfleischer@archlinux.org
State New
Headers show
Series
  • [1/2] Upgrade Sharness to 1.1.0
Related show

Commit Message

Lukas Fleischer Nov. 23, 2019, 5:31 p.m. UTC
We support multiple database backends. Don't require Python modules for
all backends to be installed.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
---
 aurweb/db.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Patch

diff --git a/aurweb/db.py b/aurweb/db.py
index 0b58197..c6d4de1 100644
--- a/aurweb/db.py
+++ b/aurweb/db.py
@@ -1,5 +1,12 @@ 
-import mysql.connector
-import sqlite3
+try:
+    import mysql.connector
+except ImportError:
+    pass
+
+try:
+    import sqlite3
+except ImportError:
+    pass
 
 import aurweb.config