I am trying to add JSON data posted from client to my database, the code I've tried with:
@app.route('/postjson', methods=['POST'])
def postEventViewer():
print(request.is_json)
content = request.get_json()
items = []
for item in content:
items.append(item['Values'])
items.append(item['Count'])
items.append(item['Group'])
items.append(item['Name'])
values = item['Values']
count = item['Count']
group = item['Group']
name = item['Name']
engine.execute('INSERT INTO EventViewer (Values, Count, Group, Name) VALUES (:value, :count, :group, :name)', value=values, count=count, group=group, name=name)
This gives me the following error:
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near "Values": syntax error
But using the same code with less parameters in a equivalent database works fine and adds to the database just as expected:
engine.execute('INSERT INTO person (name, balance) VALUES (:name, :balance)', name=name, balance=count)
What am I doing wrong here? Thanks!