diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/db.py | 7 | ||||
-rw-r--r-- | src/index.py | 8 |
2 files changed, 12 insertions, 3 deletions
@@ -10,9 +10,9 @@ import os import sys import time -import couch -from index import CouchIindex +import couch +import index class DictDB(): @@ -42,11 +42,12 @@ class DictDB(): try: self.couchdb = self.server.database(self.database) + print("Database already exists") except couch.exceptions.NotFound: print("Creating database and indexes.") self.couchdb = self.server.create(self.database) - for i in CouchIindex(): + for i in index.as_list(): self.couchdb.index(i) self._ts = time.time() diff --git a/src/index.py b/src/index.py index 3541ec7..688ceeb 100644 --- a/src/index.py +++ b/src/index.py @@ -51,3 +51,11 @@ class CouchIindex(BaseSettings): "name": "asn-country-code-json-index", "type": "json" } + + +def as_list(): + index_list = list() + for item in CouchIindex().dict(): + index_list.append(CouchIindex().dict()[item]) + + return index_list |