-1
Good Afternoon! How do I take the data that comes back from the sql query and play it in a list knowing that I need to return the query = to return the file folder + the files larger than the query.? Thanks for your help.
#Busca no banco de dados o ultimo Id inserido
cursor = conn.cursor()
cursor.execute('Select posicao, ArquivoLog from logbin where Id = (select max(Id) from logbin)')
recordset = cursor.fetchall()
execucao_anterior = recordset[0]
#Retorno da consulta mysql
#bin-log.000028
#le os arquivos da pasta logs
os.chdir("C:\\Backups\\Logs\\")
lista = glob.glob("*.0*")
tm_lista = (len(lista))
posicao_na_lista = ((lista.index(arquivo_anterior)))
print(posicao_na_lista)
#retorno
#bin-log.000028
#bin-log.000029
#bin-log.000030
#bin-log.000031
Lucas thanks for the help, but I really need to do a comparison of the data I have a database that stores the log information. in my query above I look for the last insertion in my bd, now I need to compare with the files I search in the folder with those of the query and save in a variable. bd query return was bin-log.000035 And I have in the folder of the following files 'bin-log.000034', 'bin-log.000035', 'bin-log.000036', 'bin-log.000037', 'bin-log.000038' I need to get the files [bin-log.000035', 'bin-log.000036', 'bin-log.000037', 'bin-log.000038' And play in a variable.
– Junior Medeiros
Suddenly you can use the contents of this link: https://answall.com/questions/200249/listar-somente-arquivos-sem-pastas-em-dir%C3%A9torio-em-python It is demonstrated how to list the files of a given directory, then just compare the two lists in a for and the different saved in a variable.
– Lucas da Costa