Esempio n. 1
0
 def __init__(
     self,
     tablename,
 ):
     db = MongoClient().doca
     collist = db.list_collection_names()
     if tablename in collist:
         self.table = db[tablename]
     else:
         raise TableNotFoundError
Esempio n. 2
0
def migrate():
    db = MongoClient().doca

    for table in tables:

        collist = db.list_collection_names()
        if table['table_name'] not in collist:
            print(table['table_name'])
            myTable = db[table['table_name']]
            if 'id' in table:
                myTable.create_index([(table['id'], pymongo.ASCENDING)],
                                     unique=True)