def addForeignKeys(cls, mapTables, ifNotExists=True):
 if (not filter(None, [col.foreignKey for col in cls._imdbpySchema.cols])):
  return
 fakeTableName = ('myfaketable%s' % cls.sqlmeta.table)
 if (fakeTableName in FAKE_TABLES_REPOSITORY):
  newcls = FAKE_TABLES_REPOSITORY[fakeTableName]
 else:
  newcls = _buildFakeFKTable(cls, fakeTableName)
  FAKE_TABLES_REPOSITORY[fakeTableName] = newcls
 newcls.setConnection(cls._connection)
 for col in cls._imdbpySchema.cols:
  if (col.name == 'id'):
   continue
  if (not col.foreignKey):
   continue
  fkQuery = newcls._connection.createReferenceConstraint(newcls, newcls.sqlmeta.columns[col.name])
  if (not fkQuery):
   continue
  fkQuery = fkQuery.replace('myfaketable', '')
  newcls._connection.query(fkQuery)
 newcls._connection.close()

def addForeignKeys ( cls , mapTables , ifNotExists = True ) : if ( not filter ( None , [ col . foreignKey for col in cls . _imdbpySchema . cols ] ) ) : return fakeTableName = ( 'myfaketable%s' % cls . sqlmeta . table ) if ( fakeTableName in FAKE_TABLES_REPOSITORY ) : newcls = FAKE_TABLES_REPOSITORY [ fakeTableName ] else : newcls = _buildFakeFKTable ( cls , fakeTableName ) FAKE_TABLES_REPOSITORY [ fakeTableName ] = newcls newcls . setConnection ( cls . _connection ) for col in cls . _imdbpySchema . cols : if ( col . name == 'id' ) : continue if ( not col . foreignKey ) : continue fkQuery = newcls . _connection . createReferenceConstraint ( newcls , newcls . sqlmeta . columns [ col . name ] ) if ( not fkQuery ) : continue fkQuery = fkQuery . replace ( 'myfaketable' , '' ) newcls . _connection . query ( fkQuery ) newcls . _connection . close ( )
create all required foreign keys .