I have been trying to split lines from a file and save that split data into variables without success.
My code is now like this:
cur = db.cursor()
query = """INSERT INTO xxxx (var1, var2) VALUES (%s, %s)"""
with open('data.txt') as f:
da = f.readlines()
for line in da:
values = (v1,v2)
cur.execute(query,values)
But it doesn't work as I want.
My request is if any of you can help me to get from data.txt the values needed and saved to variables to be able to send them as a query to the database.
data.txt has now this:
0013a200419e323b <=>€#356894040#XBEE#0#STR:XBee frame#BAT:1#
0013a200419e323b <=>€#356894040#XBEE#0#STR:XBee frame#BAT:1#
So var1 has to be equal to 0013a200419e323b and var2 to <=>€#356894040#XBEE#0#STR:XBee frame#BAT:1#
fline.split('<=>')?