from datetime import datetime from app import db from models.postmodel import Post from sqlalchemy.exc import (DatabaseError, DataError, IntegrityError, InterfaceError, InvalidRequestError) def schedule_text(request): print(request.form["text"]) try: post = Post( content=request.form["text"], last_updated=datetime.now(), scheduled_time=datetime.now(), ) db.session.add(post) db.session.commit() except DatabaseError: db.session.rollback() return "post scheduled"