CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
ora::SchemaUtils Namespace Reference

Functions

void cleanUp (const std::string &connectionString, std::set< std::string > exclusionList=std::set< std::string >())
 

Function Documentation

void ora::SchemaUtils::cleanUp ( const std::string &  connectionString,
std::set< std::string >  exclusionList = std::set<std::string>() 
)

Definition at line 22 of file SchemaUtils.cc.

References python.IdGenerator::schema, python.CommonUtils::session, lumiQTWidget::t, and dataDML::tables.

Referenced by TestFunct::DropTables().

22  {
23  coral::ConnectionService connServ;
24  std::auto_ptr<coral::ISessionProxy> session( connServ.connect( connectionString, coral::Update ));
25  session->transaction().start();
26  try{
27  coral::ISchema& schema = session->nominalSchema();
28  std::set<std::string> tables = schema.listTables();
29  for( std::set<std::string>::const_iterator iEx = exclusionList.begin();
30  iEx != exclusionList.end(); ++iEx ){
31  tables.erase( *iEx );
32  }
33  for( std::set<std::string>::const_iterator iT = tables.begin();
34  iT != tables.end(); ++iT ){
35  coral::ITable& t = schema.tableHandle( *iT );
36  int numFKs = t.description().numberOfForeignKeys();
37  for( int ifk=0; ifk < numFKs; ifk++ ){
38  // workaround: since the dropFK triggers a commit, the fk list is reset. therefore, always drop the fk id=0!!!
39  t.schemaEditor().dropForeignKey( t.description().foreignKey( 0 ).name() );
40  };
41  }
42  for( std::set<std::string>::const_iterator iT = tables.begin();
43  iT != tables.end(); ++iT ){
44  schema.dropIfExistsTable( *iT );
45  }
46  session->transaction().commit();
47  } catch ( ... ){
48  session->transaction().rollback();
49  throw;
50  }
51 }
tuple tables
Definition: dataDML.py:2329