hello can some help me to add 2 list to a database(mysql) in python, here is the code but i can figure out where is the problem (i am new to mysql).
def scan(self):
"""Scan the pc for instaled app in `desktop`"""
file_location = []
file_name = []
ending = ('.url','.lnk','.rtf')
desktop = os.path.join(os.path.join(os.environ['USERPROFILE']),'OneDrive', 'Desktop')
exclude = set(['one drive'])
for r, dirs, f in os.walk(desktop, topdown=True):
dirs[:] = [d for d in dirs if d not in exclude]
for file in f:
if file.endswith(ending):
file_location.append(r + "\\" + file)
for f_name in os.listdir(desktop):
if f_name.endswith(tuple(ending)):
file_name.append(f_name)
query2 = ("INSERT INTO application (app_name) VALUES (%s)")
query3 = ("INSERT INTO application (app_location) VALUES (%s)")
my_cursor.executemany(query2, [(n, ) for n in file_name])
my_cursor.executemany(query3, [(l, ) for l in file_location])
mydb.commit()
and this is the error that i have:
TypeError: executemany() takes 3 positional arguments but 4 were given
the result that i need is to place file_name
and file_location
in the same row but different colon respectively
ex:
file_name | file_location
fornite | fortnite.exe