Changeset 7 for trunk/lib/nanownlib/storage.py
- Timestamp:
- 07/09/15 12:58:10 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/nanownlib/storage.py
r4 r7 14 14 conn = None 15 15 cursor = None 16 _population_sizes = None 17 16 18 def __init__(self, path): 17 19 exists = os.path.exists(path) … … 19 21 self.conn.execute("PRAGMA foreign_keys = ON;") 20 22 self.conn.row_factory = sqlite3.Row 23 self._population_sizes = {} 21 24 22 25 if not exists: … … 86 89 self.conn.close() 87 90 91 def populationSize(self, probe_type): 92 if probe_type in self._population_sizes: 93 return self._population_sizes[probe_type] 94 95 try: 96 cursor = self.conn.cursor() 97 cursor.execute("SELECT max(c) FROM (SELECT count(sample) c FROM probes WHERE type=? GROUP BY test_case)", (probe_type,)) 98 self._population_sizes[probe_type] = cursor.fetchone()[0] 99 return self._population_sizes[probe_type] 100 except Exception as e: 101 print(e) 102 return 0 103 88 104 def _insert(self, table, row): 89 105 rid = _newid()
Note: See TracChangeset
for help on using the changeset viewer.