ERROR CLOSING CONNECTION: mysql connection close

johnny rampeters at gmail.com
Fri Dec 8 16:33:05 EST 2006


I am getting following connection error from my python script:

    conn.close()
AttributeError: adodb_mysql instance has no attribute 'close'

Here is my relevant code below:

def worker(tq):
    while True:
        host, e = tq.get()

        c = ftplib.FTP(host)
        c.connect()
        try:
            c.login()
            p = os.path.basename(e)
            download_dir = r'H:/ftp_download/'
            ps_dir = r'H:/ftp_download/'
            filename = download_dir+p
            fp = open(filename, 'wb')
            try: c.retrbinary('RETR %s' % e, fp.write)
            finally: fp.close()
        finally: c.close()
        if (p.lower().endswith('.ps') ):
            partFileName = p.split('.', 1)
            movedFile = download_dir + p
            #movedFile = p
            finalFile = ps_dir + partFileName[0]+'.pdf'
            encode_cmd = r'ps2pdf '+ movedFile + ' '+ finalFile
            os.system(encode_cmd)

        conn = adodb.NewADOConnection('mysql')
        conn.Connect('localhost', 'temp', 'temp', 'temp')

        sql = r"update video set pdf_file_path='" +finalFile+r"' where
file_path='"+p+r"'"


        cursor = conn.Execute(sql)
        rows = cursor.Affected_Rows()

        cursor = conn.Execute(sql)
        rows = cursor.Affected_Rows()
        cursor.close()
        conn.close()
            
        tq.task_done()




More information about the Python-list mailing list