(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, inf in tables.items():
            if skytools.exists_table(dcur, tbl):
                continue

            sql = self.part_template
            sql = sql.replace('_DEST_TABLE', skytools.quote_fqident(inf['table']))
            sql = sql.replace('_PARENT', skytools.quote_fqident(inf['parent']))
            sql = sql.replace('_PKEY', inf['key_list'])
            # be similar to table_dispatcher
            schema_table = inf['table'].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 , inf in tables . items ( ) : if skytools . exists_table ( dcur , tbl ) : continue sql = self . part_template sql = sql . replace ( '_DEST_TABLE' , skytools . quote_fqident ( inf [ 'table' ] ) ) sql = sql . replace ( '_PARENT' , skytools . quote_fqident ( inf [ 'parent' ] ) ) sql = sql . replace ( '_PKEY' , inf [ 'key_list' ] ) # be similar to table_dispatcher schema_table = inf [ 'table' ] . 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 ) )