Hi,
I am using Python 2.3.4 in Linux environment.
I have some sql files, I execute sql files in a loop. I want to generate seprate log files for every sql files in loop. How can I do this.

regards
pankaj

Sorry but i don't understand what you want...
Can you post your code ? part of your sql files ?
How do you execute the content of your sql files ?
What do you want to write in your logfile ?
Your question in far too open for me to answer.

I want to generate seprate log files for every sql files in loop.

You would open a unique file within the loop, before you start reading the SQL file, and close the file after the last record is copied. That's pretty basic so perhaps I am missing something.

def cpi_subsql(args):
try:
loginfo = main._initlogger()
logger = logging.getLogger(loginfo)
if args == "":
args = raw_input('Please Enter Sql file name:')
if args == "":
sys.exit

cpi_run_sql.cpi_runsql(args)
except:
logger.exception("Error while executing cpi_sub_sql")
raise

args is argument that is a sql file. I need the output in a seprate file.
For example- args is S00198.sql. I need S00198.log file that will be output of S00198.sql file

please put [ code] [ /code] tags around your code...
I still don't understand the problem...
I know neither what your logger is nor how and where you want to write in your logfile.
To determine the name of your logfile, you can do something like this

def cpi_subsql(args):
    try:
        loginfo = main._initlogger()
        logger = logging.getLogger(loginfo)
        if args == "":
            args = raw_input('Please Enter Sql file name:')
            if args == "":
                sys.exit

        # determine logfile name
        # Here, i take the sql file name, replacing the .sql with a .log
        logfilename="%s.log" % args[:-4]
        # but as I don't know how you wish to use it, i can't do anything more...
        cpi_run_sql.cpi_runsql(args)
    except:
        logger.exception("Error while executing cpi_sub_sql")
        raise
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.