Hello..

I have function as below to create logfile and write logs to it. It works fine in python shell. But once you convert it into sql server query, its not working. Any idea why so?

import logging
import time
from datetime import datetime
labellog = "C:\LabelLog" + datetime.now().strftime("%Y%m%d_%H%M%S")+".log"
logging.basicConfig(filename=labellog,format='%(asctime)s %(message)s',level=logging.DEBUG)

def writelogfile(a, strg):
    lbstr1 = ' function started'
    lbstr2 = ' function completed'
    if a == 1:
        logging.debug(strg+lbstr1)
    elif a == 0:
        logging.debug(strg+lbstr2)


def prntfl():
    strg = prntfl.func_name
    writelogfile(1,strg)
    global var
    var = 'This is a function'
    logging.debug(var)
    writelogfile(0,strg)

I see no SQL in your code and the functions are never called. I would write:

def writelogfile(a, strg):
    logging.debug(strg + (' function completed', ' function started')[a])
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.