2
I want to generate a service order number, I have the code, but I want it to consult in the database the last number of the service order that was generated.
Follows the code:
def rangeOrdemServ(self):
db = self.conexaoBanco()
cursor = db.cursor()
cursor.execute("select ordem_serv_num from ordem_serv where id = LAST_INSERT_ID()")
dadosOrdemServ = cursor.fetchall()
db.commit()
global rec
pStart = dadosOrdemServ
pInterval = +1
if (rec == 0):
dado = pStart + pInterval
self.entrOrdServ.insert(END,dado)
else:
rec += pInterval
return rec
The mistake:
Traceback (most recent call last):
File "E:/CharIp ServerFTP_1.1/CharIP_1.1.7/Ordem_Servicos.py", line 152, in <module>
sis(root)
File "E:/CharIp ServerFTP_1.1/CharIP_1.1.7/Ordem_Servicos.py", line 21, in __init__
self.telaOrdServ()
File "E:/CharIp ServerFTP_1.1/CharIP_1.1.7/Ordem_Servicos.py", line 108, in telaOrdServ
self.rangeOrdemServ()
File "E:/CharIp ServerFTP_1.1/CharIP_1.1.7/Ordem_Servicos.py", line 119, in rangeOrdemServ
dado = pStart + pInterval
TypeError: can only concatenate tuple (not "int") to tuple
could give me an example: and that I don’t have much experience
– Diunior Ronaldo Brum Lauser
@Diuniorronaldobrumlauser I did just that use the cursor already instantiated by adding the lastrowid to validate ....
– Otto
it worked, however it returns me 1 and not the next sequence. ex: 000570370 the next one would be 000570371
– Diunior Ronaldo Brum Lauser
@Diuniorronaldobrumlauser I believe it helps you now
– Otto
solved this question thank you, now my problem and take this data and add it to +1 to generate the sequence, ex: 000570370 to 000570371
– Diunior Ronaldo Brum Lauser
@Diuniorronaldobrumlauser you take the return and put +1, it is very simple, take the opportunity to mark the question as solved
– Otto
I’m going to create another theme to see because I’ve already picked up the return and added one more just not right
– Diunior Ronaldo Brum Lauser
Perfect @Diuniorronaldobrumlauser it’s nice to separate ask for topics so it’s easier to find
– Otto