A
A
AltLumad2018-11-15 12:25:53
Python
AltLumad, 2018-11-15 12:25:53

Python why object is recognized as str?

Have a function

def get_zreport(idstore, zdate):
    сonn = get_connect()
    cursor = сonn.cursor()
    qt = DBQ.ZReport(cursor, idstore, zdate)
    qt.open()
    qt.fetchall()
    result = {'zreport' : []}
    while(qt.read()):
        shifts = result['zreport']
        idx = len(shifts)
        if idx == 0 or shifts[idx-1]['idshift'] != qt.idshift:
            sh = {'idshift' : qt.idshift,
                 'iddevice' : qt.iddevice,
                 'zdate' : zdate,
                 'position' : [] }
            shifts.append(sh)
        
        position = {'idproduct' :  qt.idproduct,
                    'quantity' : qt.quantity}
        
        sh['position'].append(position)

        qt.next()
    сonn.close()    
    return result

There is a class
class ZReport(Query):
    def __init__(self, cursor, idstore, zdate):
        sql = '''select s.idshift, cv.iddevice, s.open, s.close, c.idproduct, sum(c.ammount) as quantity from shift s
                    left join cashvoucher cv on cv.uuidsession = s.uuid and cv.idstore = s.uuidstore 
                    inner join cost c on c.idcashvoucher = cv.idcashvoucher
                where s.close::date = %(zdate)s::date
                  and s.uuidstore = %(idstore)s
                group by s.idshift, cv.iddevice, c.idproduct
                order by s.open'''
        param = {'idstore' : idstore, 'zdate' : zdate }

        super().__init__(cursor, sql, param)  

        self.idshift = -1
        self.iddevice = ''
        self.open = ''
        self.close = ''
        self.idproduct = -1
        self.quantity = 0

I get this error
File "C:\service\clientrequest.py", line 52, in get_zreport
qt.open()
TypeError: 'str' object is not callable
Other Query descendants work fine under similar conditions.
What is the reason for this strange behaviour?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question