(self, dcon, tables)
Checks that tables needed for copy are there. If not
        then creates them.

        Used by other procedures to ensure that table is there
        before they start inserting.

        The commits should not be dangerous, as we haven't done anything
        with cdr's yet, so they should still be in one TX.

        Although it would be nicer to have a lock for table creation.
Checks that tables needed for copy are there. If not
        then creates them.
Checks that tables needed for copy are there . If not then creates them .
def check_tables(self, dcon, tables):
        """Checks that tables needed for copy are there. If not
        then creates them.

        Used by other procedures to ensure that table is there
        before they start inserting.

        The commits should not be dangerous, as we haven't done anything
        with cdr's yet, so they should still be in one TX.

        Although it would be nicer to have a lock for table creation.
        """

        dcur = dcon.cursor()
        for tbl in tables.keys():
            if not skytools.exists_table(dcur, tbl):
                if not self.part_template:
                    raise Exception('Dest table does not exists and no way to create it.')

                sql = self.part_template
                sql = sql.replace(DEST_TABLE, skytools.quote_fqident(tbl))

                # we do this to make sure that constraints for 
                # tables who contain a schema will still work
                schema_table = tbl.replace(".", "__")
                sql = sql.replace(SCHEMA_TABLE, skytools.quote_ident(schema_table))

                dcur.execute(sql)
                dcon.commit()
                self.log.info('%s: Created table %s' % (self.job_name, tbl))
def check_tables ( self , dcon , tables ) : dcur = dcon . cursor ( ) for tbl in tables . keys ( ) : if not skytools . exists_table ( dcur , tbl ) : if not self . part_template : raise Exception ( 'Dest table does not exists and no way to create it.' ) sql = self . part_template sql = sql . replace ( DEST_TABLE , skytools . quote_fqident ( tbl ) ) # we do this to make sure that constraints for  # tables who contain a schema will still work schema_table = tbl . replace ( "." , "__" ) sql = sql . replace ( SCHEMA_TABLE , skytools . quote_ident ( schema_table ) ) dcur . execute ( sql ) dcon . commit ( ) self . log . info ( '%s: Created table %s' % ( self . job_name , tbl ) )