You connect using SqlAlchemy oracle database, there are some problems in the use of conventional query date criteria queries, such as:
OrderMain.query.filter. (OrderMain.createtime> = "to_date ( '" + str (year) + "- 01-01', 'yyyy-mm-dd')") all () found at the non-required input digital numeric characters
OrderMain.query.filter (OrderMain.createtime> = '2019-01-01'). All () does not match the text and format string
Then you need OrderMain.query.filter (OrderMain.createtime> = datetime (2019,1,1) .all () can check out properly.