def __schemaRemove(self, schemaDefObj): """Test case - remove table schema using schema definition""" ret = 0 try: tableIdList = schemaDefObj.getTableIdList() sqlGen = SqlGenAdmin(self.__verbose, serverType="cratedb") sqlL = [] for tableId in tableIdList: if tableId in self.__tableIdSkipD: continue tableDefObj = schemaDefObj.getTable(tableId) sqlL.extend( sqlGen.dropTableSQL( databaseName=schemaDefObj.getVersionedDatabaseName(), tableDefObj=tableDefObj)) sqlL.extend( sqlGen.dropTableSQL( databaseName=schemaDefObj.getDatabaseName(), tableDefObj=tableDefObj)) logger.debug("Schema Remove SQL string\n %s", "\n".join(sqlL)) with Connection(cfgOb=self.__cfgOb, resourceName=self.__resourceName) as client: crQ = CrateDbQuery(dbcon=client, verbose=self.__verbose) ret = crQ.sqlCommandList(sqlCommandList=sqlL) logger.debug("Schema remove command returns %r\n", ret) return ret # except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def testConnection(self): try: with Connection(cfgOb=self.__cfgOb, resourceName=self.__resourceName) as client: self.assertNotEqual(client, None) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def loadInsertMany(self, dataList, procName, optionsD, workingDir): try: _ = workingDir ret = None sd = optionsD["sd"] skipD = optionsD["skip"] ioObj = IoAdapter(verbose=self.__verbose) logger.debug("%s pathlist %r", procName, dataList) with Connection(cfgOb=self.__cfgOb, resourceName=self.__resourceName) as client: sdl = CrateDbLoader(schemaDefObj=sd, ioObj=ioObj, dbCon=client, workPath=self.__workPath, cleanUp=False, warnings="default", verbose=self.__verbose) ret = sdl.load(inputPathList=dataList, loadType="crate-insert-many", deleteOpt="selected", tableIdSkipD=skipD) # all or nothing here if ret: return dataList, dataList, [] else: return [], [], [] except Exception as e: logger.info("Failing with dataList %r", dataList) logger.exception("Failing with %s", str(e)) return [], [], []
def testLoadInsertManyPdbxExampleFiles(self): try: sd, _, _, _ = self.__schP.getSchemaInfo(databaseName="pdbx") self.__schemaCreate(schemaDefObj=sd) inputPathList = self.__rpP.getLocatorObjList(contentType="pdbx") with Connection(cfgOb=self.__cfgOb, resourceName=self.__resourceName) as client: sdl = CrateDbLoader(schemaDefObj=sd, ioObj=self.__ioObj, dbCon=client, workPath=self.__workPath, cleanUp=False, warnings="default", verbose=self.__verbose) ret = sdl.load(inputPathList=inputPathList, loadType="crate-insert-many", deleteOpt="selected", tableIdSkipD=self.__tableIdSkipD) self.assertEqual(ret, True) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()