for some reason the insert instruction is painfully slow.
By painfully slow, I mean I go from 400 updates a second to about 5.
This is the method in question:
@app.route('/sendData/<path:data>', methods=['POST'])
def receiveData(data): #Data = '0,2C7,2C6,1C8,2C2,1' always.
def h(point):
cur.execute("INSERT INTO points (x, y) VALUES({},{});".format(*point.split(",")))
g.db.commit()
cur = g.db.cursor()
#list(map(h, data.split("C"))) This enables the slow.
return "Done"
When I uncomment that map, it goes painfully slow. I also tried this other method, same thing.
def receiveData(data): #Data = '0,2C7,2C6,1C8,2C2,1' always.
cur = g.db.cursor()
cur.execute("INSERT INTO points (x, y) VALUES({}, {});".format(*data.split("C",1)[0].split(",")))
g.db.commit()
if data.count("C") == 0:
return "Done"
else:
return receiveData(data.split("C",1)[1])
I don't think I need to commit every single insert, but putting it at the end of each function makes no difference.