def __schemaCreate(self, schemaDefObj): """Test case - create table schema using schema definition""" ret = 0 try: tableIdList = schemaDefObj.getTableIdList() sqlGen = SqlGenAdmin(self.__verbose, serverType="CockroachDb") dbName = schemaDefObj.getVersionedDatabaseName() sqlL = sqlGen.createDatabaseSQL(dbName) for tableId in tableIdList: tableDefObj = schemaDefObj.getTable(tableId) sqlL.extend(sqlGen.createTableSQL(databaseName=schemaDefObj.getVersionedDatabaseName(), tableDefObj=tableDefObj)) logger.debug("\nSchema creation SQL string\n %s\n\n", "\n".join(sqlL)) logger.info("Creating schema using database %s", schemaDefObj.getVersionedDatabaseName()) # with Connection(cfgOb=self.__cfgOb, resourceName=self.__resourceName) as client: crQ = CockroachDbQuery(dbcon=client, verbose=self.__verbose) ret = crQ.sqlCommandList(sqlCommandList=sqlL) # ret = crQ.sqlCommand(' '.join(sqlL)) logger.info("Schema create command returns %r\n", ret) return ret # except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def __schemaCreate(self, schemaDefObj): """Create table schema using schema definition""" try: tableIdList = schemaDefObj.getSchemaIdList() sqlGen = SqlGenAdmin(self.__verbose) sqlL = sqlGen.createDatabaseSQL(schemaDefObj.getDatabaseName()) for tableId in tableIdList: tableDefObj = schemaDefObj.getSchemaObject(tableId) sqlL.extend( sqlGen.createTableSQL( databaseName=schemaDefObj.getDatabaseName(), tableDefObj=tableDefObj)) logger.debug("Schema creation SQL string\n %s\n\n", "\n".join(sqlL)) with Connection(cfgOb=self.__cfgOb, resourceName=self.__resourceName) as client: myQ = MyDbQuery(dbcon=client, verbose=self.__verbose) # # Permit warnings to support "drop table if exists" for missing tables. # myQ.setWarning("ignore") ret = myQ.sqlCommand(sqlCommandList=sqlL) logger.debug("\n\n+INFO mysql server returns %r\n", ret) self.assertTrue(ret) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def __schemaCreateSQL(self, schemaDefObj): """Test case - create table schema using schema definition""" sqlL = [] try: tableIdList = schemaDefObj.getTableIdList() sqlGen = SqlGenAdmin(self.__verbose, serverType="CockroachDb") dbName = schemaDefObj.getVersionedDatabaseName() sqlL = sqlGen.createDatabaseSQL(dbName) for tableId in tableIdList: tableDefObj = schemaDefObj.getTable(tableId) sqlL.extend(sqlGen.createTableSQL(databaseName=schemaDefObj.getVersionedDatabaseName(), tableDefObj=tableDefObj)) logger.debug("\nSchema creation SQL string\n %s\n\n", "\n".join(sqlL)) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail() return sqlL