summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aurweb/db.py3
-rwxr-xr-xaurweb/scripts/popupdate.py1
-rw-r--r--test/test_popupdate.py5
3 files changed, 8 insertions, 1 deletions
diff --git a/aurweb/db.py b/aurweb/db.py
index 02aeba38..8b9b8ada 100644
--- a/aurweb/db.py
+++ b/aurweb/db.py
@@ -1,3 +1,5 @@
+import math
+
try:
import mysql.connector
except ImportError:
@@ -91,6 +93,7 @@ class Connection:
elif aur_db_backend == 'sqlite':
aur_db_name = aurweb.config.get('database', 'name')
self._conn = sqlite3.connect(aur_db_name)
+ self._conn.create_function("POWER", 2, math.pow)
self._paramstyle = sqlite3.paramstyle
else:
raise ValueError('unsupported database backend')
diff --git a/aurweb/scripts/popupdate.py b/aurweb/scripts/popupdate.py
index b64deedb..b1e70403 100755
--- a/aurweb/scripts/popupdate.py
+++ b/aurweb/scripts/popupdate.py
@@ -7,7 +7,6 @@ import aurweb.db
def main():
conn = aurweb.db.Connection()
-
conn.execute("UPDATE PackageBases SET NumVotes = (" +
"SELECT COUNT(*) FROM PackageVotes " +
"WHERE PackageVotes.PackageBaseID = PackageBases.ID)")
diff --git a/test/test_popupdate.py b/test/test_popupdate.py
new file mode 100644
index 00000000..93f86f10
--- /dev/null
+++ b/test/test_popupdate.py
@@ -0,0 +1,5 @@
+from aurweb.scripts import popupdate
+
+
+def test_popupdate():
+ popupdate.main()