Я пытаюсь сравнить два времени даты, и он показывает синтаксическую ошибку sql
from flask import Flask
from flask import request, jsonify
from datetime import datetime
import pymysql
app = Flask(__name__)
class Database:
def __init__(self):
host = "localhost"
user = "test"
password = "test123"
db = "test"
self.con = pymysql.connect(host=host, user=user, password=password, db=db, cursorclass=pymysql.cursors.DictCursor)
self.cur = self.con.cursor()
@app.route('/getCameraTypeAndTime/<string:date1>/<string:date2>', methods=['GET'])
def getCameraTypeAndTime(date1,date2):
start = datetime.strptime(date1, '%Y-%m-%d %H:%M:%S')
end = datetime.strptime(date2, '%Y-%m-%d %H:%M:%S')
db=Database()
result1=db.cur.execute("Select camera, COUNT(*) as freq from face_log group by camera where timestamp>start and timestamp_end<end")
return jsonify({'result': result1})
if __name__ == '__main__':
app.run(debug=True)
Формат в sql - это datetime, но он не будет сравнивать