![]() |
SQLAlchemy DateTime result 0's - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: SQLAlchemy DateTime result 0's (/thread-13157.html) |
SQLAlchemy DateTime result 0's - AMarotta97 - Oct-01-2018 Hi all, I am new here and also quite new to python, so I apologize in advance for any errors I may make, just let me know any I will prevent it in the future, thank you. So My current function is using flask, having a form to book an appointment, so far in my template for the time part is: <form action="/patient/patientbook" method="POST" role="form"> <label for="name">Start Time:</label> <input type="datetime-local" class="form-control" id="starttime" name="starttime" required> <br> </form>And inside my python script: # Databse model for a Booking class Book(db.Model): __tablename__ = 'booking' bid = db.Column(db.Integer, primary_key=True) starttime = db.Column(db.DateTime(), nullable=False) count = 1 def __init__(self, starttime): self.starttime = Book.starttime Book.count += 1 class BookSchema(ma.Schema): class Meta: # Fields to expose fields = ('bid', 'starttime') book_schema = BookSchema() books_schema = BookSchema(many=True) # Route for a patient to make a booking @app.route("/patient/patientbook", methods=["POST", "GET"]) def patientBook(): if request.method == 'POST': pemail = (request.form.get('email')) pname = (request.form.get('pname')) starttime = request.form['starttime'] print(starttime) starttime = "{}:00".format(starttime) print(starttime) if pemail and pname and starttime: new_booking = Patient(pemail, pname) new_bookingtwo = Book(starttime) db.session.add(new_booking) db.session.add(new_bookingtwo) db.session.commit() return render_template('patient/patientbook.html')And After I have completed the process and view the results in the database (google cloud db), I receive the following: Any help appreciated!Also another thing, I am working on linking up my database so that a Doctor will be linked with an appointment time with a patients email, any guide on how to do that would also be appreciated, Thank you!!! |