projects
/
quix0rs-apt-p2p.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Workaround old sqlite not having 'select count(distinct key)'.
[quix0rs-apt-p2p.git]
/
apt_p2p_Khashmir
/
db.py
diff --git
a/apt_p2p_Khashmir/db.py
b/apt_p2p_Khashmir/db.py
index 4ee9cb38068d69978828ca8c328b36d053fe15cc..bd777b60e78f65126859645a29152b49aeab80bd 100644
(file)
--- a/
apt_p2p_Khashmir/db.py
+++ b/
apt_p2p_Khashmir/db.py
@@
-154,11
+154,16
@@
class DB:
@return: the number of distinct keys and total values in the database
"""
c = self.conn.cursor()
@return: the number of distinct keys and total values in the database
"""
c = self.conn.cursor()
- c.execute("SELECT COUNT(
DISTINCT key) as num_keys, COUNT(
value) as num_values FROM kv")
-
keys, values = 0,
0
+ c.execute("SELECT COUNT(value) as num_values FROM kv")
+
values =
0
row = c.fetchone()
if row:
row = c.fetchone()
if row:
- keys, values = row[0], row[1]
+ values = row[0]
+ c.execute("SELECT COUNT(key) as num_keys FROM (SELECT DISTINCT key FROM kv)")
+ keys = 0
+ row = c.fetchone()
+ if row:
+ keys = row[0]
return keys, values
class TestDB(unittest.TestCase):
return keys, values
class TestDB(unittest.TestCase):